]> git.ozlabs.org Git - ccan/commitdiff
Fix !HAVE_TYPEOF case by using new typesafe_cb.
authorRusty Russell <rusty@vivaldi>
Thu, 28 Feb 2008 03:06:51 +0000 (14:06 +1100)
committerRusty Russell <rusty@vivaldi>
Thu, 28 Feb 2008 03:06:51 +0000 (14:06 +1100)
talloc/_info.c
talloc/talloc.h

index 2f067a42a8299582a9020b22b62dca229fb572f8..18da417faea4e484af5fb1d72b36b257884559b0 100644 (file)
@@ -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;
 }
index b73164093c043924bce74da8b30ea48be0b7b497..5566a040440a9e71f5d6947ce8f1d60cdddc3443 100644 (file)
@@ -27,6 +27,7 @@
 #include <stdio.h>
 #include <stdarg.h>
 #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