#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
#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
#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))
+++ /dev/null
-#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();
-}
_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))
* 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