aboutsummaryrefslogtreecommitdiffstats
path: root/src/mem/memcmp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mem/memcmp.c')
-rw-r--r--src/mem/memcmp.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/mem/memcmp.c b/src/mem/memcmp.c
index bcb2fb5..70419be 100644
--- a/src/mem/memcmp.c
+++ b/src/mem/memcmp.c
@@ -11,5 +11,22 @@
*/
#include <mem.h>
-extern inline int calt_memcmp(void const *ptr1, void const *ptr2, size_t count);
+int calt_memcmp(const void *ptr1, const void *ptr2, size_t count) {
+ if(ptr1 == ptr2){
+ return 0;
+ }
+
+ const unsigned char *p1 = ptr1;
+ const unsigned char *p2 = ptr2;
+
+ while (count-- > 0) {
+ if (*p1 != *p2) {
+ return (*p1 < *p2) ? -1 : 1;
+ }
+ p1++;
+ p2++;
+ }
+
+ return 0;
+}