summaryrefslogtreecommitdiff
path: root/sys/src/libc/port/memccpy.c
blob: 9268ba72eae9e6b4c0972f0cbd073a4748e61798 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include	<u.h>
#include	<libc.h>

void*
memccpy(void *a1, void *a2, int c, ulong n)
{
	uchar *s1, *s2;

	s1 = a1;
	s2 = a2;
	c &= 0xFF;
	while(n > 0) {
		if((*s1++ = *s2++) == c)
			return s1;
		n--;
	}
	return 0;
}