Commit 9a483e66 authored by David Gibson's avatar David Gibson Committed by Rusty Russell

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: default avatarDavid Gibson <david@gibson.dropbear.id.au>
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
parent 1db16ab6
......@@ -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;
}
......
......@@ -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
......@@ -16,24 +17,6 @@
#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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment