diff options
author | Marvin Borner | 2020-11-23 17:09:28 +0100 |
---|---|---|
committer | Marvin Borner | 2020-11-23 17:09:28 +0100 |
commit | 23798b52a0aa4bf556b06f15fb9f5923db3cc46f (patch) | |
tree | 352db3855bc4b0262e0477e31c1395e4652097be /libc | |
parent | d82b18c90710baf16239257272a740488fddf11c (diff) |
Ported sxml library
Diffstat (limited to 'libc')
-rw-r--r-- | libc/inc/mem.h | 1 | ||||
-rw-r--r-- | libc/mem.c | 12 |
2 files changed, 13 insertions, 0 deletions
diff --git a/libc/inc/mem.h b/libc/inc/mem.h index 8977a48..964b24b 100644 --- a/libc/inc/mem.h +++ b/libc/inc/mem.h @@ -22,6 +22,7 @@ void free(void *ptr); void *memcpy(void *dest, const void *src, u32 n); void *memset(void *dest, int val, u32 n); +void *memchr(void *src, int c, u32 n); int memcmp(const void *s1, const void *s2, u32 n); #endif @@ -43,6 +43,18 @@ void *memset(void *dest, int val, u32 n) return dest; } +void *memchr(void *src, int c, u32 n) +{ + const u8 *s = (const u8 *)src; + + while (n-- > 0) { + if (*s == c) + return (void *)s; + s++; + } + return NULL; +} + int memcmp(const void *s1, const void *s2, u32 n) { const u8 *a = (const u8 *)s1; |