9os

Experimental kernel using plan9 ideas for embedded device
git clone git://git.simple-cc.org/9os
Log | Files | Refs | README | LICENSE

memchr.c (184B)


      1 #include <string.h>
      2 #undef memchr
      3 
      4 void *
      5 memchr(const void *s, int c, size_t n)
      6 {
      7 	const unsigned char *bp = s;
      8 
      9 	while (n > 0 && *bp++ != c)
     10 		--n;
     11 	return (n == 0) ? NULL : bp-1;
     12 }