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