memccpy.c 201 B

1234567891011121314151617
  1. #include <lib9.h>
  2. void*
  3. memccpy(void *a1, void *a2, int c, ulong n)
  4. {
  5. uchar *s1, *s2;
  6. s1 = a1;
  7. s2 = a2;
  8. c &= 0xFF;
  9. while(n > 0) {
  10. if((*s1++ = *s2++) == c)
  11. return s1;
  12. n--;
  13. }
  14. return 0;
  15. }