xref: /freebsd/contrib/unbound/compat/memcmp.c (revision cc426dd31990b8b50b210efc450e404596548ca1)
1 /*
2  *	memcmp.c: memcmp compat implementation.
3  *
4  *	Copyright (c) 2010, NLnet Labs. All rights reserved.
5  *
6  * See LICENSE for the license.
7 */
8 
9 #include <config.h>
10 
11 int memcmp(const void *x, const void *y, size_t n);
12 
13 int memcmp(const void *x, const void *y, size_t n)
14 {
15 	const uint8_t* x8 = (const uint8_t*)x;
16 	const uint8_t* y8 = (const uint8_t*)y;
17 	size_t i;
18 	for(i=0; i<n; i++) {
19 		if(x8[i] < y8[i])
20 			return -1;
21 		else if(x8[i] > y8[i])
22 			return 1;
23 	}
24 	return 0;
25 }
26