musl - musl - an implementation of the standard library for Linux-based systems

index : musl
musl - an implementation of the standard library for Linux-based systems
summary refs log tree commit diff
path: root/src/string/strrchr.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2011年04月13日 08:36:29 -0400
committerRich Felker <dalias@aerifal.cx>2011年04月13日 08:36:29 -0400
commit6597f9ac133fd4f47dea307d6260fd52eae77816 (patch)
tree980c26e132ffeb5f1d6d5a8bec383c61cb0550bf /src/string/strrchr.c
parent750b738e53f799443fcfcd3a0751318c072a022f (diff)
downloadmusl-6597f9ac133fd4f47dea307d6260fd52eae77816.tar.gz
implement memrchr (nonstandard) and optimize strrchr in terms of it
Diffstat (limited to 'src/string/strrchr.c')
-rw-r--r--src/string/strrchr.c 7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/string/strrchr.c b/src/string/strrchr.c
index 31c8e0b8..9c683087 100644
--- a/src/string/strrchr.c
+++ b/src/string/strrchr.c
@@ -1,9 +1,8 @@
#include <string.h>
+void *__memrchr(const void *, int, size_t);
+
char *strrchr(const char *s, int c)
{
- const char *p;
- c = (char)c;
- for (p=s+strlen(s); p>=s && *p!=c; p--);
- return p>=s ? (char *)p : 0;
+ return __memrchr(s, c, strlen(s));
}
generated by cgit v1.2.1 (git 2.18.0) at 2025年09月09日 10:16:18 +0000

AltStyle によって変換されたページ (->オリジナル) /