blob: 65440324afff0126cae8828f1d6c54939a37c8b9 [file] [log] [blame]
Martin Rothfb8876d2022-08-07 15:12:12 -06001/* SPDX-License-Identifier: GPL-2.0-only */
2
Gabe Black1025f3a2011-09-16 02:18:56 -07003#include <string.h>
4void *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}