aboutsummaryrefslogtreecommitdiff
path: root/src/userspace/mlibc/string/memcmp.c
blob: f1f1e3fc622588b3e67c1d7dfe1f139aa91bd717 (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;
}