scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

memchr.c (185B)


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