memmove.c 615 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * Copyright (C) 2002 Manuel Novoa III
  3. * Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
  4. *
  5. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  6. */
  7. #include "_string.h"
  8. #ifdef WANT_WIDE
  9. # define Wmemmove wmemmove
  10. #else
  11. # define Wmemmove memmove
  12. #endif
  13. Wvoid *Wmemmove(Wvoid *s1, const Wvoid *s2, size_t n)
  14. {
  15. register Wchar *s = (Wchar *) s1;
  16. register const Wchar *p = (const Wchar *) s2;
  17. if (p >= s) {
  18. while (n) {
  19. *s++ = *p++;
  20. --n;
  21. }
  22. } else {
  23. while (n) {
  24. --n;
  25. s[n] = p[n];
  26. }
  27. }
  28. return s1;
  29. }
  30. #ifndef WANT_WIDE
  31. libc_hidden_def(memmove)
  32. #endif