aboutsummaryrefslogtreecommitdiffstats
path: root/src/mem/memchr.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mem/memchr.c')
-rw-r--r--src/mem/memchr.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/mem/memchr.c b/src/mem/memchr.c
index b583ab3..ed1187a 100644
--- a/src/mem/memchr.c
+++ b/src/mem/memchr.c
@@ -6,4 +6,15 @@
#include <mem.h>
-extern inline void *calt_memchr(void const *ptr, unsigned char value, size_t count);
+void *calt_memchr(void const *ptr, unsigned char value, size_t count) {
+ unsigned char const *p = ptr;
+
+ while (count-- > 0) {
+ if (*p == value) {
+ return (void *)p;
+ }
+ p++;
+ }
+
+ return NULL;
+}