shithub: drawcpu

ref: fe54357c8428219c5a27c4cbbebc8d49cc29bdf7
dir: /kern/memchr.c/

View raw version
#include	<u.h>
#include	<libc.h>

void*
sysmemchr(void *ap, int c, ulong n)
{
	uchar *sp;
	ulong i;

	i = n;
	
	sp = (uchar *)ap;
	c &= 0xFF;
	while(i > 0) {
		if(*sp++ == c)
			return sp-1;
		i--;
	}
	return 0;
}