blob: bf512989e4e033556472e91efdaba29eabd0d534 [file] [log] [blame]
// Copyright SCI Semiconductor and CHERIoT Contributors.
// SPDX-License-Identifier: MIT
#include <string.h>
void *__cheri_libcall memrchr(const void *voidString,
int intChar,
size_t n)
{
const unsigned char c = (unsigned char)intChar;
const unsigned char *s = (const unsigned char *)voidString;
s += n;
for (size_t i = n; i > 0; --i)
{
--s;
if (*s == c)
{
return (void *)s;
}
}
return NULL;
}