summaryrefslogtreecommitdiff
path: root/rushs/tinyprintf/my_memcmp/my_memcmp.c
diff options
context:
space:
mode:
Diffstat (limited to 'rushs/tinyprintf/my_memcmp/my_memcmp.c')
-rw-r--r--rushs/tinyprintf/my_memcmp/my_memcmp.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/rushs/tinyprintf/my_memcmp/my_memcmp.c b/rushs/tinyprintf/my_memcmp/my_memcmp.c
new file mode 100644
index 0000000..d498360
--- /dev/null
+++ b/rushs/tinyprintf/my_memcmp/my_memcmp.c
@@ -0,0 +1,18 @@
+#include "my_memcmp.h"
+
+int my_memcmp(const void *s1, const void *s2, size_t num)
+{
+ if (num == 0)
+ {
+ return 0;
+ }
+ const unsigned char *a = s1;
+ const unsigned char *b = s2;
+
+ for (; num - 1 && *a == *b; a++, b++, num--)
+ {
+ continue;
+ }
+
+ return *a - *b;
+}