]> git.ozlabs.org Git - ccan/commitdiff
rfc822: Use the memmem module
authorDavid Gibson <david@gibson.dropbear.id.au>
Sat, 14 Jun 2014 16:11:26 +0000 (02:11 +1000)
committerRusty Russell <rusty@rustcorp.com.au>
Mon, 16 Jun 2014 11:42:43 +0000 (21:12 +0930)
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 <david@gibson.dropbear.id.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ccan/rfc822/_info
ccan/rfc822/rfc822.c

index dac530cd84b4e369c55a54b8ed7437ced4f42931..7c3ca08eda7a0a3affc069257b1db31305f3b24c 100644 (file)
@@ -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;
        }
 
index 08c0541328396c10f0afa59486429602610b4c16..636d29a612c2c4b189af9f0fc50cfb7ad4957643 100644 (file)
@@ -8,6 +8,7 @@
 #include <ccan/list/list.h>
 #include <stdio.h>
 
+#include <ccan/memmem/memmem.h>
 #include <ccan/rfc822/rfc822.h>
 
 #ifdef TAL_USE_TALLOC
 #include <ccan/tal/tal.h>
 #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)