aboutsummaryrefslogtreecommitdiff
path: root/src/userspace/mlibc/string/memcmp.c
blob: af2125ce85912ce97519f98fa2f42f52265925ff (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <stddef.h>

int memcmp(const void *a_ptr, const void *b_ptr, size_t size)
{
    const unsigned char *a = (const unsigned char *) a_ptr;
    const unsigned char *b = (const unsigned char *) b_ptr;
    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;
}