summaryrefslogtreecommitdiff
path: root/missing/memmove.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
commitc0851c650ff75d11d301ce4965f610bae9a565be (patch)
tree896ec25a6f12877c36ce5f89cdca36be1e98f81e /missing/memmove.c
parentf44333cbff95e520e8c41b9cd455b1a16ed7cf22 (diff)
* missing.h, missing/memcmp.c, missing/memmove.c:
ANSI compatible interface. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9470 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'missing/memmove.c')
-rw-r--r--missing/memmove.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/missing/memmove.c b/missing/memmove.c
index c9d67d8..19c5f18 100644
--- a/missing/memmove.c
+++ b/missing/memmove.c
@@ -1,22 +1,21 @@
/* public domain rewrite of memcmp(3) */
+#include <stddef.h>
+
void *
-memmove (d, s, n)
- void *d, *s;
- int n;
+memmove(void *d, const void *s, size_t n)
{
- char *dst = d;
- char *src = s;
- void *ret = dst;
+ char *dst = (char *)d;
+ const char *src = (const char *)s;
if (src < dst) {
src += n;
dst += n;
- while (n--)
+ for (; n; --n)
*--dst = *--src;
}
else if (dst < src)
- while (n--)
+ for (; n; --n)
*dst++ = *src++;
- return ret;
+ return d;
}