implement memrchr (nonstandard) and optimize strrchr in terms of it
This commit is contained in:
parent
750b738e53
commit
6597f9ac13
3 changed files with 16 additions and 4 deletions
12
src/string/memrchr.c
Normal file
12
src/string/memrchr.c
Normal file
|
|
@ -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);
|
||||
Loading…
Add table
Add a link
Reference in a new issue