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

#include <stddef.h>

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

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