aboutsummaryrefslogtreecommitdiffstats
path: root/src/mem/memccpy.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mem/memccpy.c')
-rw-r--r--src/mem/memccpy.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/mem/memccpy.c b/src/mem/memccpy.c
new file mode 100644
index 0000000..71b5a94
--- /dev/null
+++ b/src/mem/memccpy.c
@@ -0,0 +1,20 @@
+#include <mem.h>
+
+void *calt_memccpy(void *restrict dest, void const *restrict src, unsigned char value,
+ size_t size) {
+ unsigned char *d = dest;
+ unsigned char const *s = src;
+
+ while (size-- > 0) {
+ *d++ = *s;
+ if (*s++ == value) {
+ return d;
+ }
+ }
+
+ return NULL;
+}
+
+extern inline void *calt_memccpy_null(void *restrict dest,
+ void const *restrict src,
+ unsigned char value, size_t size);