aboutsummaryrefslogtreecommitdiffstats
path: root/memory/memchr.c
diff options
context:
space:
mode:
Diffstat (limited to 'memory/memchr.c')
-rw-r--r--memory/memchr.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/memory/memchr.c b/memory/memchr.c
new file mode 100644
index 0000000..61c10e3
--- /dev/null
+++ b/memory/memchr.c
@@ -0,0 +1,10 @@
+#include "memory.h"
+
+void *memchr(void const *buf, int value, size_t size)
+{
+ unsigned char const *buffer = buf;
+ for (size_t i = 0; i < size; i++)
+ if (buffer[i] == (unsigned char)value)
+ return (void *)&buffer[i];
+ return NULL;
+}