summaryrefslogtreecommitdiff
path: root/lib/libc/string/memcmp.c
blob: 23a18392c9503dfde32c74908dd7b8f485e0a496 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <string.h> // for memcmp, size_t

int memcmp(const void *s1, const void *s2, size_t n)
{
	const unsigned char *p1 = s1;
	const unsigned char *p2 = s2;
	while (n--) {
		if (*p1 != *p2)
			return *p1 - *p2;
		p1++;
		p2++;
	}
	return 0;
}