2001-03-06 11:17:54 +03:00
|
|
|
/* public domain rewrite of memcmp(3) */
|
1999-08-13 09:45:20 +04:00
|
|
|
|
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) {
|
1999-08-13 09:45:20 +04:00
|
|
|
if (tmp = *a++ - *b++)
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|