scc

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

memcmp.c (248B)


      1 #include <string.h>
      2 #undef memcmp
      3 
      4 int
      5 memcmp(const void *s1, const void *s2, size_t n)
      6 {
      7 	const char *s = s1;
      8 	const char *t = s2;
      9 
     10 	for ( ; n > 0 && *s == *t; --n)
     11 		++s, ++t;
     12 
     13 	return (n > 0) ? *(unsigned char *) s - *(unsigned char *) t : 0;
     14 }