| Ambroise Vincent | ebff107 | 2019-06-19 17:14:09 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2019, Arm Limited. All rights reserved. | ||||
| 3 | * | ||||
| 4 | * SPDX-License-Identifier: BSD-3-Clause | ||||
| 5 | */ | ||||
| 6 | |||||
| 7 | #include <string.h> | ||||
| 8 | |||||
| 9 | #undef memrchr | ||||
| 10 | |||||
| 11 | void *memrchr(const void *src, int c, size_t len) | ||||
| 12 | { | ||||
| 13 | const unsigned char *s = src + (len - 1); | ||||
| 14 | |||||
| 15 | while (len--) { | ||||
| 16 | if (*s == (unsigned char)c) { | ||||
| 17 | return (void*) s; | ||||
| 18 | } | ||||
| 19 | |||||
| 20 | s--; | ||||
| 21 | } | ||||
| 22 | |||||
| 23 | return NULL; | ||||
| 24 | } | ||||