tal: adding or removing a notifier/destructor can be const.
authorRusty Russell <rusty@rustcorp.com.au>
Mon, 3 Dec 2012 08:59:38 +0000 (19:29 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Mon, 3 Dec 2012 08:59:38 +0000 (19:29 +1030)
You don't need write access to the context to attach a destructor;
it's meta.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ccan/tal/tal.c
ccan/tal/tal.h

index c9006857e599e3cea89ef39418b2dd62b0274d1a..d8a15f45c2a8ff04f43f21a4776c9eb135e693df 100644 (file)
@@ -455,14 +455,14 @@ void *tal_steal_(const tal_t *new_parent, const tal_t *ctx)
         return (void *)ctx;
 }
 
-bool tal_add_destructor_(tal_t *ctx, void (*destroy)(void *me))
+bool tal_add_destructor_(const tal_t *ctx, void (*destroy)(void *me))
 {
        tal_t *t = debug_tal(to_tal_hdr(ctx));
        return add_notifier_property(t, TAL_NOTIFY_FREE|NOTIFY_IS_DESTRUCTOR,
                                     (void *)destroy);
 }
 
-bool tal_add_notifier_(tal_t *ctx, enum tal_notify_type types,
+bool tal_add_notifier_(const tal_t *ctx, enum tal_notify_type types,
                       void (*callback)(tal_t *, enum tal_notify_type, void *))
 {
        tal_t *t = debug_tal(to_tal_hdr(ctx));
@@ -489,7 +489,7 @@ bool tal_add_notifier_(tal_t *ctx, enum tal_notify_type types,
        return true;
 }
 
-bool tal_del_notifier_(tal_t *ctx,
+bool tal_del_notifier_(const tal_t *ctx,
                       void (*callback)(tal_t *, enum tal_notify_type, void *))
 {
        struct tal_hdr *t = debug_tal(to_tal_hdr(ctx));
@@ -505,7 +505,7 @@ bool tal_del_notifier_(tal_t *ctx,
        return false;
 }
 
-bool tal_del_destructor_(tal_t *ctx, void (*destroy)(void *me))
+bool tal_del_destructor_(const tal_t *ctx, void (*destroy)(void *me))
 {
        return tal_del_notifier_(ctx, (void *)destroy);
 }
index 4e862cd631177297cdc47497d4466a6f15923dc6..10ee460812bd10860adf450abebf17e2ede85988 100644 (file)
@@ -405,13 +405,13 @@ tal_t *tal_steal_(const tal_t *new_parent, const tal_t *t);
 
 bool tal_resize_(tal_t **ctxp, size_t size);
 
-bool tal_add_destructor_(tal_t *ctx, void (*destroy)(void *me));
-bool tal_del_destructor_(tal_t *ctx, void (*destroy)(void *me));
+bool tal_add_destructor_(const tal_t *ctx, void (*destroy)(void *me));
+bool tal_del_destructor_(const tal_t *ctx, void (*destroy)(void *me));
 
-bool tal_add_notifier_(tal_t *ctx, enum tal_notify_type types,
+bool tal_add_notifier_(const tal_t *ctx, enum tal_notify_type types,
                       void (*notify)(tal_t *ctx, enum tal_notify_type,
                                      void *info));
-bool tal_del_notifier_(tal_t *ctx,
+bool tal_del_notifier_(const tal_t *ctx,
                       void (*notify)(tal_t *ctx, enum tal_notify_type,
                                      void *info));
 #endif /* CCAN_TAL_H */