blob: 01caef3aef5b02777caef0e8325a0aa681982d1d [file] [log] [blame]
Ambroise Vincent35248f22019-06-19 17:14:09 +01001/*
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
11void *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}