summaryrefslogtreecommitdiff
path: root/lib/libc/memcmp.c
diff options
context:
space:
mode:
authorAda Christine <adachristine18@gmail.com>2026-05-24 11:09:31 +0000
committerAda Christine <adachristine18@gmail.com>2026-05-24 11:09:31 +0000
commitd07bd08dd0446e8c41eccaccbb07e9112200e8ee (patch)
tree742a3f9d9d84c8ee55858b2ebc7e0e0f8c714c7c /lib/libc/memcmp.c
parent9aaf21bf10d00ec12b24499817e3e91dca08c461 (diff)
rename and move, function renames in stdio
Diffstat (limited to 'lib/libc/memcmp.c')
-rw-r--r--lib/libc/memcmp.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/libc/memcmp.c b/lib/libc/memcmp.c
new file mode 100644
index 0000000..2348afe
--- /dev/null
+++ b/lib/libc/memcmp.c
@@ -0,0 +1,16 @@
+/* Public domain. */
+#include <stddef.h>
+
+int
+memcmp (const void *str1, const void *str2, size_t count)
+{
+ const unsigned char *s1 = str1;
+ const unsigned char *s2 = str2;
+
+ while (count-- > 0)
+ {
+ if (*s1++ != *s2++)
+ return s1[-1] < s2[-1] ? -1 : 1;
+ }
+ return 0;
+}