xref: /plan9-contrib/sys/src/libc/port/memchr.c (revision ec59a3ddbfceee0efe34584c2c9981a5e5ff1ec4)
1 #include	<u.h>
2 #include	<libc.h>
3 
4 void*
5 memchr(void *ap, int c, ulong n)
6 {
7 	uchar *sp;
8 
9 	sp = ap;
10 	c &= 0xFF;
11 	while(n > 0) {
12 		if(*sp++ == c)
13 			return sp-1;
14 		n--;
15 	}
16 	return 0;
17 }
18