talloc: allow replacement allocator
[ccan] / ccan / asearch / test / compile_fail-return-value-const.c
1 #include <ccan/asearch/asearch.h>
2 #include <ccan/array_size/array_size.h>
3 #include <string.h>
4
5 static int cmp(const char *key, const char *const *elem)
6 {
7         return strcmp(key, *elem);
8 }
9
10 int main(void)
11 {
12         const char key[] = "key";
13         const char *elems[] = { "a", "big", "list", "of", "things" };
14
15 #ifdef FAIL
16         char **p;
17 #if !HAVE_TYPEOF
18 #error "Unfortunately we don't fail if no typeof."
19 #endif
20 #else
21         const char **p;
22 #endif
23         p = asearch(key, elems, ARRAY_SIZE(elems), cmp);
24         return p ? 0 : 1;
25 }