memchr.c
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #include <string.h>
4 void *memchr(const void *s, int c, size_t n)
5 {
6 const unsigned char *sc = s;
7 while (n--) {
8 if (*sc == (unsigned char)c)
9 return (void *)sc;
10 sc++;
11 }
12 return NULL;
13 }