memccpy.c 495 B

1234567891011121314151617181920
  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. /* No wide analog. */
  8. #include "_string.h"
  9. void *memccpy(void * __restrict s1, const void * __restrict s2, int c, size_t n)
  10. {
  11. register char *r1 = s1;
  12. register const char *r2 = s2;
  13. while (n-- && (((unsigned char)(*r1++ = *r2++)) != ((unsigned char) c)));
  14. return (n == (size_t) -1) ? NULL : r1;
  15. }