xref: /aosp_15_r20/external/coreboot/src/lib/memchr.c (revision b9411a12aaaa7e1e6a6fb7c5e057f44ee179a49c)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <string.h>
memchr(const void * s,int c,size_t n)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 }
14