blob: e009a5f2b5cbb66e617bf3b87b498172e726e608 [file] [log] [blame]
Antonio Nino Diaz9eddb1e2018-08-16 14:53:05 +01001/*
Boyan Karatotev7ab30812025-03-17 10:31:03 +00002 * Copyright (c) 2013-2025, Arm Limited and Contributors. All rights reserved.
Antonio Nino Diaz9eddb1e2018-08-16 14:53:05 +01003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <stddef.h>
Boyan Karatotev7ab30812025-03-17 10:31:03 +00008#include <string_private.h>
Antonio Nino Diaz9eddb1e2018-08-16 14:53:05 +01009
10void *memchr(const void *src, int c, size_t len)
11{
Ambroise Vincent782f7e62019-06-07 11:19:45 +010012 const unsigned char *s = src;
Antonio Nino Diaz9eddb1e2018-08-16 14:53:05 +010013
14 while (len--) {
Ambroise Vincent782f7e62019-06-07 11:19:45 +010015 if (*s == (unsigned char)c)
Antonio Nino Diaz9eddb1e2018-08-16 14:53:05 +010016 return (void *) s;
17 s++;
18 }
19
20 return NULL;
21}