xref: /rk3399_ARM-atf/lib/libc/memchr.c (revision ee656609c8e9292f65ad82100f4ca190b7882a05)
1 /*
2  * Copyright (c) 2013-2025, Arm Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #include <stddef.h>
8 #include <string_private.h>
9 
10 void *memchr(const void *src, int c, size_t len)
11 {
12 	const unsigned char *s = src;
13 
14 	while (len--) {
15 		if (*s == (unsigned char)c)
16 			return (void *) s;
17 		s++;
18 	}
19 
20 	return NULL;
21 }
22