Antonio Nino Diaz | 9eddb1e | 2018-08-16 14:53:05 +0100 | [diff] [blame] | 1 | /* |
Ambroise Vincent | b237bca | 2019-02-13 15:58:00 +0000 | [diff] [blame] | 2 | * Copyright (c) 2013-2019, ARM Limited and Contributors. All rights reserved. |
Antonio Nino Diaz | 9eddb1e | 2018-08-16 14:53:05 +0100 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <stddef.h> |
Ambroise Vincent | b237bca | 2019-02-13 15:58:00 +0000 | [diff] [blame] | 8 | #include <string.h> |
Antonio Nino Diaz | 9eddb1e | 2018-08-16 14:53:05 +0100 | [diff] [blame] | 9 | |
| 10 | void *memchr(const void *src, int c, size_t len) |
| 11 | { |
Ambroise Vincent | 782f7e6 | 2019-06-07 11:19:45 +0100 | [diff] [blame] | 12 | const unsigned char *s = src; |
Antonio Nino Diaz | 9eddb1e | 2018-08-16 14:53:05 +0100 | [diff] [blame] | 13 | |
| 14 | while (len--) { |
Ambroise Vincent | 782f7e6 | 2019-06-07 11:19:45 +0100 | [diff] [blame] | 15 | if (*s == (unsigned char)c) |
Antonio Nino Diaz | 9eddb1e | 2018-08-16 14:53:05 +0100 | [diff] [blame] | 16 | return (void *) s; |
| 17 | s++; |
| 18 | } |
| 19 | |
| 20 | return NULL; |
| 21 | } |