Commit fcccd358 authored by Alexei Fedorov's avatar Alexei Fedorov Committed by TrustedFirmware Code Review
Browse files

Merge "libc: add memrchr" into integration

parents 2bcaeab6 ebff1072
......@@ -19,6 +19,7 @@ int memcmp(const void *s1, const void *s2, size_t len);
int strcmp(const char *s1, const char *s2);
int strncmp(const char *s1, const char *s2, size_t n);
void *memchr(const void *src, int c, size_t len);
void *memrchr(const void *src, int c, size_t len);
char *strchr(const char *s, int c);
void *memset(void *dst, int val, size_t count);
size_t strlen(const char *s);
......
......@@ -12,6 +12,7 @@ LIBC_SRCS := $(addprefix lib/libc/, \
memcmp.c \
memcpy.c \
memmove.c \
memrchr.c \
memset.c \
printf.c \
putchar.c \
......
/*
* Copyright (c) 2019, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <string.h>
#undef memrchr
void *memrchr(const void *src, int c, size_t len)
{
const unsigned char *s = src + (len - 1);
while (len--) {
if (*s == (unsigned char)c) {
return (void*) s;
}
s--;
}
return NULL;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment