[ccan] [PATCH] Add configurator test for memmem()

David Gibson david at gibson.dropbear.id.au
Fri Mar 18 19:29:16 EST 2011


memmem(), which searches for one bytestring in a longer
bytestring is one of those functions that should be standard, but
isn't.  This patch adds a ccan configurator test for the function
so that modules can use or replace it as necessary.

Signed-off-by: David Gibson <david at gibson.dropbear.id.au>
---
 tools/configurator/configurator.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/tools/configurator/configurator.c b/tools/configurator/configurator.c
index 837ef8c..c75c8f0 100644
--- a/tools/configurator/configurator.c
+++ b/tools/configurator/configurator.c
@@ -105,6 +105,12 @@ static struct test tests[] = {
 	  "union { int i; char c[sizeof(int)]; } u;\n"
 	  "u.i = 0x01020304;\n"
 	  "return u.c[0] == 0x04 && u.c[1] == 0x03 && u.c[2] == 0x02 && u.c[3] == 0x01 ? 0 : 1;" },
+	{ "HAVE_MEMMEM", DEFINES_FUNC, NULL,
+	  "#define _GNU_SOURCE\n"
+	  "#include <string.h>\n"
+	  "static void *func(void *h, size_t hl, void *n, size_t nl) {\n"
+	  "return memmem(h, hl, n, nl);"
+	  "}\n", },
 	{ "HAVE_MMAP", DEFINES_FUNC, NULL,
 	  "#include <sys/mman.h>\n"
 	  "static void *func(int fd) {\n"
-- 
1.7.1



More information about the ccan mailing list