Browse Source

typesafe_cb: fix fallout from API changes.

Rusty Russell 15 years ago
parent
commit
d707abbb2f

+ 2 - 2
ccan/asearch/asearch.h

@@ -3,7 +3,7 @@
 #include <stdlib.h>
 #include <stdlib.h>
 #include <ccan/typesafe_cb/typesafe_cb.h>
 #include <ccan/typesafe_cb/typesafe_cb.h>
 
 
-/*
+/**
  * asearch - search an array of elements
  * asearch - search an array of elements
  * @key: pointer to item being searched for
  * @key: pointer to item being searched for
  * @base: pointer to data to sort
  * @base: pointer to data to sort
@@ -24,7 +24,7 @@
 #define asearch(key, base, num, cmp)					\
 #define asearch(key, base, num, cmp)					\
 	((__typeof__(*(base))*)(bsearch((key), (base), (num), sizeof(*(base)), \
 	((__typeof__(*(base))*)(bsearch((key), (base), (num), sizeof(*(base)), \
 		cast_if_type(int (*)(const void *, const void *),	\
 		cast_if_type(int (*)(const void *, const void *),	\
-			     (cmp),					\
+			     (cmp), &*(cmp),				\
 			     int (*)(const __typeof__(*(key)) *,	\
 			     int (*)(const __typeof__(*(key)) *,	\
 				     const __typeof__(*(base)) *)))))
 				     const __typeof__(*(base)) *)))))
 #else
 #else

+ 1 - 1
ccan/asort/asort.h

@@ -19,7 +19,7 @@
 #define asort(base, num, cmp, ctx)					\
 #define asort(base, num, cmp, ctx)					\
 _asort((base), (num), sizeof(*(base)),					\
 _asort((base), (num), sizeof(*(base)),					\
        cast_if_type(int (*)(const void *, const void *, const void *),	\
        cast_if_type(int (*)(const void *, const void *, const void *),	\
-		    (cmp),						\
+		    (cmp), &*(cmp),					\
 		    int (*)(const __typeof__(*(base)) *,		\
 		    int (*)(const __typeof__(*(base)) *,		\
 			    const __typeof__(*(base)) *,		\
 			    const __typeof__(*(base)) *,		\
 			    __typeof__(ctx))), (ctx))
 			    __typeof__(ctx))), (ctx))

+ 0 - 22
ccan/asort/test/run-strings.c

@@ -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();
-}

+ 2 - 2
ccan/hashtable/hashtable.h

@@ -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 *),	\
 	_hashtable_traverse(ht, cast_if_type(bool (*)(void *, void *),	\
 					     cast_if_any(bool (*)(void *, \
 					     cast_if_any(bool (*)(void *, \
 								  void *), \
 								  void *), \
-							 (cb), (cb),	\
+							 (cb), &*(cb),	\
 							 bool (*)(const type *,	\
 							 bool (*)(const type *,	\
 								  const typeof(*cbarg) *), \
 								  const typeof(*cbarg) *), \
 							 bool (*)(type *, \
 							 bool (*)(type *, \
 								  const typeof(*cbarg) *), \
 								  const typeof(*cbarg) *), \
 							 bool (*)(const type *,	\
 							 bool (*)(const type *,	\
 								  typeof(*cbarg) *)), \
 								  typeof(*cbarg) *)), \
-					     (cb),		\
+					     &*(cb),		\
 					     bool (*)(type *, typeof(*cbarg) *)), \
 					     bool (*)(type *, typeof(*cbarg) *)), \
 			    (cbarg))
 			    (cbarg))
 
 

+ 1 - 1
ccan/talloc/talloc.h

@@ -196,7 +196,7 @@ int talloc_free(const void *ptr);
  *	talloc, talloc_free
  *	talloc, talloc_free
  */
  */
 #define talloc_set_destructor(ptr, function)				      \
 #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
  * talloc_zero - allocate zeroed dynamic memory for a type