summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/string/memmove.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/string/memmove.c b/src/string/memmove.c
index 22677b6d..5d6dd3e0 100644
--- a/src/string/memmove.c
+++ b/src/string/memmove.c
@@ -10,16 +10,17 @@ void * memmove(void *s1, const void *s2, size_t n)
ASSERT_NONNULL(s2);
if (s1 < s2) {
- return memcpy(s1, s2, n);
- }
-
- /* reverse memcpy() */
- while (n > 0) {
+ for (size_t i = 0; i < n; i++) {
+ ((char*)s1)[i] = ((char*)s2)[i];
+ }
+ } else {
+ while (n > 0) {
+ ((char*)s1)[n] = ((char*)s2)[n];
+ n--;
+ }
+ /* last byte */
((char*)s1)[n] = ((char*)s2)[n];
- n--;
}
- /* last byte */
- ((char*)s1)[n] = ((char*)s2)[n];
/*
RETURN_ALWAYS(ARGUMENT(s1));