1 /* 2 ** Copyright 2001, Manuel J. Petit. All rights reserved. 3 ** Distributed under the terms of the NewOS License. 4 */ 5 6 #include <sys/types.h> 7 #include <string.h> 8 9 10 void * 11 memchr(void const *buf, int c, size_t len) 12 { 13 unsigned char const *b = buf; 14 unsigned char x = (c&0xff); 15 size_t i; 16 17 for (i = 0; i < len; i++) { 18 if (b[i] == x) 19 return (void*)(b + i); 20 } 21 22 return NULL; 23 } 24 25