diff options
Diffstat (limited to 'lib/string.c')
-rw-r--r-- | lib/string.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/string.c b/lib/string.c index ad6db47fa..d63f624d9 100644 --- a/lib/string.c +++ b/lib/string.c @@ -363,3 +363,17 @@ char * strstr(const char * s1,const char * s2) return NULL; } #endif + +#ifndef __HAVE_ARCH_MEMCHR +void *memchr(const void *s, int c, size_t n) +{ + unsigned char *p = s; + while (n-- != 0) { + if ((unsigned char)c == *p++) { + return p-1; + } + } + return NULL; +} + +#endif |