From: Rusty Russell Date: Thu, 28 Feb 2008 03:06:51 +0000 (+1100) Subject: Fix !HAVE_TYPEOF case by using new typesafe_cb. X-Git-Url: http://git.ozlabs.org/?p=ccan;a=commitdiff_plain;h=58785e0bf9c4ac9f704415bb120fdbdb70152afa Fix !HAVE_TYPEOF case by using new typesafe_cb. --- diff --git a/talloc/_info.c b/talloc/_info.c index 2f067a42..18da417f 100644 --- a/talloc/_info.c +++ b/talloc/_info.c @@ -94,8 +94,10 @@ int main(int argc, char *argv[]) if (argc != 2) return 1; - if (strcmp(argv[1], "depends") == 0) + if (strcmp(argv[1], "depends") == 0) { + printf("typesafe_cb\n"); return 0; + } return 1; } diff --git a/talloc/talloc.h b/talloc/talloc.h index b7316409..5566a040 100644 --- a/talloc/talloc.h +++ b/talloc/talloc.h @@ -27,6 +27,7 @@ #include #include #include "config.h" +#include "typesafe_cb/typesafe_cb.h" /* this uses a little trick to allow __LINE__ to be stringified @@ -171,10 +172,7 @@ int talloc_free(void *ptr); * talloc, talloc_free */ #define talloc_set_destructor(ptr, function) \ - do { \ - int (*_talloc_destructor_fn)(_TALLOC_TYPEOF(ptr)) = (function); \ - _talloc_set_destructor((ptr), (int (*)(void *))_talloc_destructor_fn); \ - } while(0) + _talloc_set_destructor((ptr), typesafe_cb(int, (function), (ptr))) /** * talloc_zero - allocate zeroed dynamic memory for a type