Plan 9 from User Space's /usr/local/plan9/9pm/src/libc/port/memchr.c

#include	<9pm/u.h>
#include	<9pm/libc.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;
}

Space Glenda

Copyright © 2005 Lucent Technologies, Russ Cox, MIT.
See license for details.