| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "build-defs.h" | ||
| 2 | #include <string.h> | ||
| 3 | #include "xmemrchr.h" | ||
| 4 | |||
| 5 | 347 | void *xmemrchr(const void *ptr, int c, size_t n) | |
| 6 | { | ||
| 7 | #if HAVE_MEMRCHR | ||
| 8 | 347 | return memrchr(ptr, c, n); | |
| 9 | #endif | ||
| 10 | |||
| 11 | for (const unsigned char *s = ptr; n--; ) { | ||
| 12 | if (s[n] == (unsigned char)c) { | ||
| 13 | return (void*)(s + n); | ||
| 14 | } | ||
| 15 | } | ||
| 16 | |||
| 17 | return NULL; | ||
| 18 | } | ||
| 19 |