summaryrefslogtreecommitdiff
path: root/src/string/memcmp.c
blob: d00093ea7303158f9f32683609cb88085033d98d (plain)
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#if 0

#include <string.h>
#include "_assert.h"

/** compare memory regions **/

int memcmp(const void *s1, const void *s2, size_t n)
{
	unsigned char *p = (void*)s1;
	unsigned char *q = (void*)s2;
	size_t i = 0;

	ASSERT_NONNULL(s1);
	ASSERT_NONNULL(s2);

	for (i = 0; i < n; i++) {
		if (p[i] != q[i]) {
			return p[i] - q[i];
		}
	}

	/*
	RETURN(NEGATIVE, ARGUMENT(s1) is less than ARGUMENT(s2));
	RETURN(ZERO, ARGUMENT(s1) and ARGUMENT(s2) are equal);
	RETURN(POSITIVE(), ARGUMENT(s1) is greater than ARGUMENT(s2));
	*/
	return 0;
}

/***
compares the first ARGUMENT(n) bytes of memory at ARGUMENT(s1)
and ARGUMENT(s2).
***/

/*
STDC(1)
*/


#endif