2001-03-06 03:17:54 -05:00
|
|
|
/* public domain rewrite of memcmp(3) */
|
1999-08-13 01:45:20 -04:00
|
|
|
|
2010-07-28 04:12:01 -04:00
|
|
|
#include "ruby/missing.h"
|
2005-10-26 22:55:18 -04:00
|
|
|
#include <stddef.h>
|
|
|
|
|
1999-08-13 01:45:20 -04:00
|
|
|
int
|
2005-10-26 22:55:18 -04:00
|
|
|
memcmp(const void *s1, const void *s2, size_t len)
|
1999-08-13 01:45:20 -04:00
|
|
|
{
|
|
|
|
register unsigned char *a = (unsigned char*)s1;
|
|
|
|
register unsigned char *b = (unsigned char*)s2;
|
|
|
|
register int tmp;
|
|
|
|
|
2005-10-26 22:55:18 -04:00
|
|
|
for (; len; --len) {
|
2019-08-19 01:43:15 -04:00
|
|
|
tmp = *a++ - *b++;
|
|
|
|
if (tmp)
|
1999-08-13 01:45:20 -04:00
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|