summaryrefslogtreecommitdiff
path: root/missing/memcmp.c
blob: 9edc9c13b9f92d0aa42fc39123f150eb9924b6b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/* public domain rewrite of memcmp(3) */

int
memcmp(s1,s2,len)
    char *s1;
    char *s2;
    register int len;
{
    register unsigned char *a = (unsigned char*)s1;
    register unsigned char *b = (unsigned char*)s2;
    register int tmp;

    while (len--) {
	if (tmp = *a++ - *b++)
	    return tmp;
    }
    return 0;
}