From d3f8196eb2cd57fec5f6e2691fdbc802c4d92fc8 Mon Sep 17 00:00:00 2001 From: Anton Kling Date: Wed, 17 Apr 2024 16:20:12 +0200 Subject: LibC: Add memchr() --- userland/libc/string/memchr.c | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 userland/libc/string/memchr.c (limited to 'userland/libc/string/memchr.c') diff --git a/userland/libc/string/memchr.c b/userland/libc/string/memchr.c new file mode 100644 index 0000000..cef3bc2 --- /dev/null +++ b/userland/libc/string/memchr.c @@ -0,0 +1,11 @@ +#include + +void *memchr(const void *s, int c, size_t n) { + const char *p = s; + for (; n > 0; n--, p++) { + if (*p == c) { + return (void*)p; + } + } + return NULL; +} -- cgit v1.2.3