mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-19 02:54:24 +00:00

The previous implementation could behave incorrectly because of the sign extension of the char when compared to the int. Change-Id: I397838b0ec87a6f1af6972d022a8c19a5184b447 Signed-off-by: Ambroise Vincent <ambroise.vincent@arm.com>
21 lines
351 B
C
21 lines
351 B
C
/*
|
|
* Copyright (c) 2013-2019, ARM Limited and Contributors. All rights reserved.
|
|
*
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
*/
|
|
|
|
#include <stddef.h>
|
|
#include <string.h>
|
|
|
|
void *memchr(const void *src, int c, size_t len)
|
|
{
|
|
const unsigned char *s = src;
|
|
|
|
while (len--) {
|
|
if (*s == (unsigned char)c)
|
|
return (void *) s;
|
|
s++;
|
|
}
|
|
|
|
return NULL;
|
|
}
|