shithub: scc

ref: 5ac3a0d4c1a9d7e4d3912c4770084b885007aca6
dir: /src/libc/string/memchr.c/

View raw version
#include <string.h>

#undef memchr

void *
memchr(const void *s, int c, size_t n)
{
	unsigned char *bp = (unsigned char *) s;

	while (n > 0 && *bp++ != c)
		--n;
	return (n == 0) ? NULL : bp-1;
}