chiark / gitweb /
[PATCH] klibc: update to version 0.196
[elogind.git] / klibc / klibc / memrchr.c
1 /*
2  * memrchr.c
3  */
4
5 #include <stddef.h>
6 #include <string.h>
7
8 void *memrchr(const void *s, int c, size_t n)
9 {
10   const unsigned char *sp =
11     (const unsigned char *)s + n - 1;
12
13   while ( n-- ) {
14     if ( *sp == (unsigned char)c )
15       return (void *)sp;
16     sp--;
17   }
18
19   return NULL;
20 }