blob: 7bd3a7e3053935b571f92ffcd1f32733b899c28f [file] [log] [blame]
Ambroise Vincent4128f9f2019-02-11 13:34:41 +00001/*
Ambroise Vincent80512742019-06-20 10:03:17 +01002 * Copyright (c) 2013-2019, ARM Limited and Contributors. All rights reserved.
Ambroise Vincent4128f9f2019-02-11 13:34:41 +00003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <stddef.h>
8
9void *memchr(const void *src, int c, size_t len)
10{
Ambroise Vincent80512742019-06-20 10:03:17 +010011 const unsigned char *s = src;
Ambroise Vincent4128f9f2019-02-11 13:34:41 +000012
13 while (len--) {
Ambroise Vincent80512742019-06-20 10:03:17 +010014 if (*s == (unsigned char)c)
Ambroise Vincent4128f9f2019-02-11 13:34:41 +000015 return (void *) s;
16 s++;
17 }
18
19 return NULL;
20}