scc

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

memchr.c (197B)


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