summaryrefslogtreecommitdiff
path: root/src/libc/memset.c
blob: 31dba02ed89b1dbd8f7461a8b760b9cad1904cc9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "string.h"

/**
 * memset: sets `len` bytes to `val` starting at address `dest`.
 *
 * @see There are two other memsets in this codebase, Lib_MemSet(), MemSet()
 *
 * @param dest address to start at
 * @param val value to write (int, but interpreted as u8)
 * @param len number of bytes to write
 *
 * @return dest
 */
void* memset(void* dest, int val, size_t len) {
    char* ptr = dest;

    while (len--) {
        *ptr++ = val;
    }
    return dest;
}