remove dependency of wmemmove on wmemcpy direction
authorRich Felker <dalias@aerifal.cx>
Fri, 7 Sep 2012 00:28:42 +0000 (20:28 -0400)
committerRich Felker <dalias@aerifal.cx>
Fri, 7 Sep 2012 00:28:42 +0000 (20:28 -0400)
unlike the memmove commit, this one should be fine to leave in place.
wmemmove is not performance-critical, and even if it were, it's
already copying whole 32-bit words at a time instead of bytes.

src/string/wmemmove.c

index 49608ca..89041c3 100644 (file)
@@ -3,9 +3,9 @@
 
 wchar_t *wmemmove(wchar_t *d, const wchar_t *s, size_t n)
 {
 
 wchar_t *wmemmove(wchar_t *d, const wchar_t *s, size_t n)
 {
-       if ((size_t)(d-s) < n) {
+       if ((size_t)(d-s) < n)
                while (n--) d[n] = s[n];
                while (n--) d[n] = s[n];
-               return d;
-       }
-       return wmemcpy(d, s, n);
+       else
+               while (n--) *d++ = *s++;
+       return d;
 }
 }