summaryrefslogtreecommitdiff
path: root/lib/libc/string/memchr.c
blob: 9da3265eba1f707a1c269a0642c9cdcd761f7b7e (plain)
1
2
3
4
5
6
7
8
9
10
11
#include <string.h>

void *memchr(const void *s, int c, size_t n) {
	const char *p = s;
	while (n--) {
		if ((char)c == *p++) {
			return (void*)(p-1);
		}
	}
	return NULL;
}