From 6597f9ac133fd4f47dea307d6260fd52eae77816 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Wed, 13 Apr 2011 08:36:29 -0400 Subject: implement memrchr (nonstandard) and optimize strrchr in terms of it --- src/string/memrchr.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/string/memrchr.c (limited to 'src/string/memrchr.c') diff --git a/src/string/memrchr.c b/src/string/memrchr.c new file mode 100644 index 00000000..a78e9d6c --- /dev/null +++ b/src/string/memrchr.c @@ -0,0 +1,12 @@ +#include +#include "libc.h" + +void *__memrchr(const void *m, int c, size_t n) +{ + const unsigned char *s = m; + c = (unsigned char)c; + while (n--) if (s[n]==c) return (void *)(s+n); + return 0; +} + +weak_alias(__memrchr, memrchr); -- cgit v1.2.1