k-tana-zero/libs/libc/memchr.c

13 lines
178 B
C
Raw Normal View History

#include <stddef.h>
void *memchr(const void *s, int c, size_t n)
{
const char *data = s;
while (n--)
if (*data++ == (char)c)
return (void *)(data - 1);
return NULL;
}