projects
/
musl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
implement memrchr (nonstandard) and optimize strrchr in terms of it
[musl]
/
src
/
string
/
memrchr.c
diff --git a/src/string/memrchr.c
b/src/string/memrchr.c
new file mode 100644
(file)
index 0000000..
a78e9d6
--- /dev/null
+++ b/
src/string/memrchr.c
@@ -0,0
+1,12
@@
+#include <string.h>
+#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);