diff options
Diffstat (limited to 'libs/libc/mem.c')
-rw-r--r-- | libs/libc/mem.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/libs/libc/mem.c b/libs/libc/mem.c index 080c88d..27f0416 100644 --- a/libs/libc/mem.c +++ b/libs/libc/mem.c @@ -48,6 +48,18 @@ void *memset(void *dest, u32 val, u32 n) return dest; } +const void *memcchr(const void *src, char c, u32 n) +{ + const u8 *s = (const u8 *)src; + + while (n-- > 0) { + if (*s == c) + return s; + s++; + } + return NULL; +} + void *memchr(void *src, char c, u32 n) { u8 *s = (u8 *)src; @@ -98,6 +110,14 @@ void *memset_user(void *dest, u32 val, u32 n) return ret; } +const void *memcchr_user(const void *src, char c, u32 n) +{ + stac(); + const void *ret = memcchr(src, c, n); + clac(); + return ret; +} + void *memchr_user(void *src, char c, u32 n) { stac(); |