This repository has been archived on 2024-06-25. You can view files and clone it, but cannot push or open issues or pull requests.
rockOS/libc/string/memcmp.c
2022-07-18 09:59:04 +03:00

15 lines
377 B
C

#include <string.h>
int memcmp(const void* aptr, const void* bptr, size_t size) {
const unsigned char* a = (const unsigned char*) aptr;
const unsigned char* b = (const unsigned char*) bptr;
for (size_t i = 0; i < size; i++) {
if (a[i] < b[i]) {
return -1;
} else if (b[i] < a[i]) {
return 1;
}
}
return 0;
}