summaryrefslogtreecommitdiff
path: root/missing/memcmp.c
blob: a81eec4244187057105d253b76081598430f9390 (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) */

#include "ruby/missing.h"
#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;
}