lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2002 Manuel Novoa III |
| 3 | * Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org> |
| 4 | * |
| 5 | * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. |
| 6 | */ |
| 7 | |
| 8 | #include "_string.h" |
| 9 | |
| 10 | #ifdef __USE_GNU |
| 11 | void *memrchr(const void *s, int c, size_t n) |
| 12 | { |
| 13 | register const unsigned char *r; |
| 14 | |
| 15 | r = ((unsigned char *)s) + ((size_t) n); |
| 16 | |
| 17 | while (n) { |
| 18 | if (*--r == ((unsigned char)c)) { |
| 19 | return (void *) r; /* silence the warning */ |
| 20 | } |
| 21 | --n; |
| 22 | } |
| 23 | |
| 24 | return NULL; |
| 25 | } |
| 26 | |
| 27 | libc_hidden_def(memrchr) |
| 28 | #endif |