summaryrefslogtreecommitdiff
path: root/userland/libc/string/memchr.c
blob: cef3bc226c047b5689f380708657e948eacc3a80 (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;
  for (; n > 0; n--, p++) {
    if (*p == c) {
      return (void*)p;
    }
  }
  return NULL;
}