summaryrefslogtreecommitdiff
path: root/missing/memcmp.c
diff options
context:
space:
mode:
Diffstat (limited to 'missing/memcmp.c')
-rw-r--r--missing/memcmp.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/missing/memcmp.c b/missing/memcmp.c
index 5b3afd7ccc..9657e6c372 100644
--- a/missing/memcmp.c
+++ b/missing/memcmp.c
@@ -1,19 +1,18 @@
/* public domain rewrite of memcmp(3) */
-#include "missing.h"
+#include "ruby/missing.h"
+#include <stddef.h>
int
-memcmp(s1,s2,len)
- char *s1;
- char *s2;
- register int len;
+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;
- while (len--) {
- if (tmp = *a++ - *b++)
+ for (; len; --len) {
+ tmp = *a++ - *b++;
+ if (tmp)
return tmp;
}
return 0;