summaryrefslogtreecommitdiff
path: root/sys/src/libc/port/memccpy.c
blob: 9fc3716c8cb74f6d53be8715a88b10b1ab472e0c (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, usize n)
{
	uchar *s1, *s2;

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