typesafe_cb: fix fallout from API changes.
authorRusty Russell <rusty@rustcorp.com.au>
Tue, 15 Jun 2010 10:10:44 +0000 (19:40 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Tue, 15 Jun 2010 10:10:44 +0000 (19:40 +0930)
ccan/asearch/asearch.h
ccan/asort/asort.h
ccan/asort/test/run-strings.c [deleted file]
ccan/hashtable/hashtable.h
ccan/talloc/talloc.h

index 8e317b47cf4d110a88d57815e7cce83bc18fb5fe..84625d986d6adef3848dbcdcc71dfa3bfe826afb 100644 (file)
@@ -3,7 +3,7 @@
 #include <stdlib.h>
 #include <ccan/typesafe_cb/typesafe_cb.h>
 
-/*
+/**
  * asearch - search an array of elements
  * @key: pointer to item being searched for
  * @base: pointer to data to sort
@@ -24,7 +24,7 @@
 #define asearch(key, base, num, cmp)                                   \
        ((__typeof__(*(base))*)(bsearch((key), (base), (num), sizeof(*(base)), \
                cast_if_type(int (*)(const void *, const void *),       \
-                            (cmp),                                     \
+                            (cmp), &*(cmp),                            \
                             int (*)(const __typeof__(*(key)) *,        \
                                     const __typeof__(*(base)) *)))))
 #else
index ffef1f6fe9e394b9697812982cfd46e964436e4f..731f9bde4cc1e868bec846c19dff1b7502fc204b 100644 (file)
@@ -19,7 +19,7 @@
 #define asort(base, num, cmp, ctx)                                     \
 _asort((base), (num), sizeof(*(base)),                                 \
        cast_if_type(int (*)(const void *, const void *, const void *), \
-                   (cmp),                                              \
+                   (cmp), &*(cmp),                                     \
                    int (*)(const __typeof__(*(base)) *,                \
                            const __typeof__(*(base)) *,                \
                            __typeof__(ctx))), (ctx))
diff --git a/ccan/asort/test/run-strings.c b/ccan/asort/test/run-strings.c
deleted file mode 100644 (file)
index 3ec4538..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#include <ccan/asearch/asearch.h>
-#include <ccan/array_size/array_size.h>
-#include <ccan/tap/tap.h>
-#include <stdlib.h>
-
-static int cmp(const int *key, const char *const *elem)
-{
-       return *key - atoi(*elem);
-}
-
-int main(void)
-{
-       const char *args[] = { "1", "4", "7", "9" };
-       int key = 7;
-       const char **p;
-
-       plan_tests(1);
-       p = asearch(&key, args, ARRAY_SIZE(args), cmp);
-       ok1(p == &args[2]);
-
-       return exit_status();
-}
index 7aa27fb30f36587babd15bce8482ecbb8d9e3ffa..cd878952bd4eb08e5b673b7783d468b85182cd6d 100644 (file)
@@ -75,14 +75,14 @@ bool hashtable_del(struct hashtable *ht, unsigned long hash, const void *p);
        _hashtable_traverse(ht, cast_if_type(bool (*)(void *, void *),  \
                                             cast_if_any(bool (*)(void *, \
                                                                  void *), \
-                                                        (cb), (cb),    \
+                                                        (cb), &*(cb),  \
                                                         bool (*)(const type *, \
                                                                  const typeof(*cbarg) *), \
                                                         bool (*)(type *, \
                                                                  const typeof(*cbarg) *), \
                                                         bool (*)(const type *, \
                                                                  typeof(*cbarg) *)), \
-                                            (cb),              \
+                                            &*(cb),            \
                                             bool (*)(type *, typeof(*cbarg) *)), \
                            (cbarg))
 
index 54a702050e96d73409c8169e5ac58b11b359fc68..e4f15aeecbb1b9dde7909525da89e88c727936e9 100644 (file)
@@ -196,7 +196,7 @@ int talloc_free(const void *ptr);
  *     talloc, talloc_free
  */
 #define talloc_set_destructor(ptr, function)                                 \
-       _talloc_set_destructor((ptr), typesafe_cb(int, (function), (ptr)))
+       _talloc_set_destructor((ptr), typesafe_cb_def(int, (function), (ptr)))
 
 /**
  * talloc_zero - allocate zeroed dynamic memory for a type