mirror of
https://github.com/diegocr/libnix.git
synced 2025-12-08 14:58:32 +00:00
18 lines
251 B
C
18 lines
251 B
C
#include <stdlib.h>
|
|
|
|
void *memrchr(const void *s, int c, size_t n)
|
|
{
|
|
const unsigned char *p = s;
|
|
const unsigned char *q = s;
|
|
|
|
p += n - 1;
|
|
|
|
while (p >= q) {
|
|
if (*p == (unsigned char)c)
|
|
return (void *)p;
|
|
p--;
|
|
}
|
|
|
|
return NULL;
|
|
}
|