diff options
Diffstat (limited to 'usr')
| -rw-r--r-- | usr/sdk/common/string/memset.c | 20 | ||||
| -rw-r--r-- | usr/sdk/inc/sdk/string.h | 11 |
2 files changed, 31 insertions, 0 deletions
diff --git a/usr/sdk/common/string/memset.c b/usr/sdk/common/string/memset.c new file mode 100644 index 0000000..ac0b4a2 --- /dev/null +++ b/usr/sdk/common/string/memset.c @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025, Ian Moffett. + * Provided under the BSD-3 clause. + */ + +#include <sdk/string.h> + +void * +memset(void *s, int c, USIZE n) +{ + if (s == NULL) { + return NULL; + } + + for (USIZE i = 0; i < n; ++i) { + ((BYTE *)s)[i] = c; + } + + return s; +} diff --git a/usr/sdk/inc/sdk/string.h b/usr/sdk/inc/sdk/string.h index 9e648d9..7233c50 100644 --- a/usr/sdk/inc/sdk/string.h +++ b/usr/sdk/inc/sdk/string.h @@ -29,6 +29,17 @@ USIZE strlen(const char *str); void *memcpy(void *dest, const void *src, USIZE count); /* + * Fill a memory area with a number of bytes + * + * @s: Target memory area + * @c: Bytes to fill with + * @n: Number of bytes + * + * Returns 's' on success + */ +void *memset(void *s, int c, USIZE n); + +/* * Compare two strings to see if they are equal. * * @s1: First string |
