shithub: p9-stm32-example-os

ref: f801657f77f3923ec2388c25bdcb036c8019ba89
dir: /libkern/memchr.c/

View raw version
#include	<u.h>
#include	"kern.h"

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

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