diff options
-rw-r--r-- | src/string/memmove.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/string/memmove.c b/src/string/memmove.c index 22bb4b35..9153a644 100644 --- a/src/string/memmove.c +++ b/src/string/memmove.c @@ -5,10 +5,9 @@ void *memmove(void *dest, const void *src, size_t n) char *d = dest; const char *s = src; if (d==s) return d; - if ((size_t)(d-s) < n) { + if ((size_t)(d-s) < n) while (n--) d[n] = s[n]; - return dest; - } - /* Assumes memcpy is overlap-safe when dest < src */ - return memcpy(d, s, n); + else + while (n--) *d++ = *s++; + return dest; } |