summaryrefslogtreecommitdiff
path: root/missing/memmove.c
diff options
context:
space:
mode:
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;
}