File: memcmp.c

package info (click to toggle)
nsd3 3.2.5-1.squeeze2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 3,160 kB
  • ctags: 3,534
  • sloc: ansic: 21,814; python: 2,085; yacc: 1,368; makefile: 583; sh: 278
file content (25 lines) | stat: -rw-r--r-- 472 bytes parent folder | download | duplicates (15)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*
 *	memcmp.c: memcmp compat implementation.
 *
 *	Copyright (c) 2010, NLnet Labs. All rights reserved.
 *
 * See LICENSE for the license.
*/

#include <config.h>

int memcmp(const void *x, const void *y, size_t n);

int memcmp(const void *x, const void *y, size_t n)
{
	const uint8_t* x8 = (const uint8_t*)x;
	const uint8_t* y8 = (const uint8_t*)y;
	size_t i;
	for(i=0; i<n; i++) {
		if(x8[i] < y8[i])
			return -1;
		else if(x8[i] > y8[i])
			return 1;
	}
	return 0;
}