xref: /haiku/src/system/libroot/posix/string/memcmp.c (revision 68ea01249e1e2088933cb12f9c28d4e5c5d1c9ef)
1 /*
2  * Copyright 2008, Axel Dörfler, axeld@pinc-software.de.
3  * Distributed under the terms of the MIT license.
4  */
5 
6 
7 #include <string.h>
8 
9 
10 int
11 memcmp(const void *_a, const void *_b, size_t count)
12 {
13 	const unsigned char *a = (const unsigned char *)_a;
14 	const unsigned char *b = (const unsigned char *)_b;
15 
16 	while (count-- > 0) {
17 		int cmp = *a++ - *b++;
18 		if (cmp != 0)
19 			return cmp;
20 	}
21 
22 	return 0;
23 }
24