]> git.lizzy.rs Git - plan9front.git/blob - sys/src/libc/port/memccpy.c
9268ba72eae9e6b4c0972f0cbd073a4748e61798
[plan9front.git] / sys / src / libc / port / memccpy.c
1 #include        <u.h>
2 #include        <libc.h>
3
4 void*
5 memccpy(void *a1, void *a2, int c, ulong n)
6 {
7         uchar *s1, *s2;
8
9         s1 = a1;
10         s2 = a2;
11         c &= 0xFF;
12         while(n > 0) {
13                 if((*s1++ = *s2++) == c)
14                         return s1;
15                 n--;
16         }
17         return 0;
18 }