diff options
author | Dimitris Papastamos <dimitris.papastamos@arm.com> | 2018-08-22 14:40:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-22 14:40:50 +0100 |
commit | 6d4f6aea2cd96a4a57ffa2d88b9230e2cab88f28 (patch) | |
tree | 251ed2d6ebe98576eaa9e1871f3aef753552125b /lib/libc/memchr.c | |
parent | 11dfe0b49ac8fcb5d1b516a3f52b06bc433ff4d9 (diff) | |
parent | 8422a8406b7d2d8e01c113e24eca167854981dfe (diff) |
Merge pull request #1528 from antonio-nino-diaz-arm/an/libc
libc: Cleanup library
Diffstat (limited to 'lib/libc/memchr.c')
-rw-r--r-- | lib/libc/memchr.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/libc/memchr.c b/lib/libc/memchr.c new file mode 100644 index 00000000..2eba47c9 --- /dev/null +++ b/lib/libc/memchr.c @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include <stddef.h> + +void *memchr(const void *src, int c, size_t len) +{ + const char *s = src; + + while (len--) { + if (*s == c) + return (void *) s; + s++; + } + + return NULL; +} |