From: David Gibson Date: Sat, 14 Jun 2014 16:11:26 +0000 (+1000) Subject: rfc822: Use the memmem module X-Git-Url: https://git.ozlabs.org/?p=ccan;a=commitdiff_plain;h=9a483e66096528915f59d875931a48eab523ca82 rfc822: Use the memmem module This changes rfc822 to use the memmem module to supply a memmem() function if the C library lacks it, instead of rolling our own locally. Signed-off-by: David Gibson Signed-off-by: Rusty Russell --- diff --git a/ccan/rfc822/_info b/ccan/rfc822/_info index dac530cd..7c3ca08e 100644 --- a/ccan/rfc822/_info +++ b/ccan/rfc822/_info @@ -65,6 +65,7 @@ int main(int argc, char *argv[]) printf("ccan/list\n"); printf("ccan/str\n"); printf("ccan/bytestring\n"); + printf("ccan/memmem\n"); return 0; } diff --git a/ccan/rfc822/rfc822.c b/ccan/rfc822/rfc822.c index 08c05413..636d29a6 100644 --- a/ccan/rfc822/rfc822.c +++ b/ccan/rfc822/rfc822.c @@ -8,6 +8,7 @@ #include #include +#include #include #ifdef TAL_USE_TALLOC @@ -16,24 +17,6 @@ #include #endif -#if !HAVE_MEMMEM -void *memmem(const void *haystack, size_t haystacklen, - const void *needle, size_t needlelen) -{ - const char *p, *last; - - p = haystack; - last = p + haystacklen - needlelen; - - do { - if (memcmp(p, needle, needlelen) == 0) - return (void *)p; - } while (p++ <= last); - - return NULL; -} -#endif - static void (*allocation_failure_hook)(const char *); static void NORETURN default_allocation_failure(const char *s)