1 // Copyright 2016 The Fuchsia Authors
2 // Copyright 2001, Manuel J. Petit.
3 // Copyright (c) 2008 Travis Geiselbrecht
4 //
5 // Use of this source code is governed by a MIT-style
6 // license that can be found in the LICENSE file or at
7 // https://opensource.org/licenses/MIT
8 
9 #include <string.h>
10 #include <sys/types.h>
11 
12 void *
memchr(void const * buf,int c,size_t len)13 memchr(void const *buf, int c, size_t len)
14 {
15     size_t i;
16     unsigned char const *b= buf;
17     unsigned char        x= (c&0xff);
18 
19     for (i= 0; i< len; i++) {
20         if (b[i]== x) {
21             return (void *)(b+i);
22         }
23     }
24 
25     return NULL;
26 }
27 
28