1 /* 2 * Copyright (C) 1991, 1992 Linus Torvalds 3 */ 4 5 #include <xen/string.h> 6 7 /** 8 * memchr - Find a character in an area of memory. 9 * @s: The memory area 10 * @c: The byte to search for 11 * @n: The size of the area. 12 * 13 * returns the address of the first occurrence of @c, or %NULL 14 * if @c is not found 15 */ 16 void *(memchr)(const void *s, int c, size_t n) 17 { 18 const unsigned char *p = s; 19 20 while (n--) 21 if ((unsigned char)c == *p++) 22 return (void *)(p - 1); 23 24 return NULL; 25 } 26 27 /* 28 * Local variables: 29 * mode: C 30 * c-file-style: "BSD" 31 * c-basic-offset: 8 32 * tab-width: 8 33 * indent-tabs-mode: t 34 * End: 35 */ 36