summaryrefslogtreecommitdiffstats
path: root/missing/memcmp.c
diff options
context:
space:
mode:
authorocean <ocean@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-10-27 02:55:18 +0000
committerocean <ocean@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-10-27 02:55:18 +0000
commit501aeb540a2ec1faf68893c0c70c3520109242a9 (patch)
tree896ec25a6f12877c36ce5f89cdca36be1e98f81e /missing/memcmp.c
parentd0d89f93c70cff3dec1d7d25453ab9b8756db4da (diff)
downloadruby-501aeb540a2ec1faf68893c0c70c3520109242a9.tar.gz
ruby-501aeb540a2ec1faf68893c0c70c3520109242a9.tar.xz
ruby-501aeb540a2ec1faf68893c0c70c3520109242a9.zip
* missing.h, missing/memcmp.c, missing/memmove.c:
ANSI compatible interface. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@9470 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'missing/memcmp.c')
-rw-r--r--missing/memcmp.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/missing/memcmp.c b/missing/memcmp.c
index 9edc9c13b..5b3ad3817 100644
--- a/missing/memcmp.c
+++ b/missing/memcmp.c
@@ -1,16 +1,15 @@
/* public domain rewrite of memcmp(3) */
+#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--) {
+ for (; len; --len) {
if (tmp = *a++ - *b++)
return tmp;
}