]> git.ozlabs.org Git - ccan/blobdiff - ccan/tal/tal.h
tal: adding or removing a notifier/destructor can be const.
[ccan] / ccan / tal / tal.h
index 8ee27c36ed1dce69e45d40187f976b23292712a2..10ee460812bd10860adf450abebf17e2ede85988 100644 (file)
@@ -127,6 +127,9 @@ void *tal_free(const tal_t *p);
  * @ptr: The tal allocated object.
  * @function: the function to call before it's freed.
  *
+ * This is a more convenient form of tal_add_notifier(@ptr,
+ * TAL_NOTIFY_FREE, ...), in that the function prototype takes only @ptr.
+ *
  * Note that this can only fail if your allocfn fails and your errorfn returns.
  */
 #define tal_add_destructor(ptr, function)                                    \
@@ -187,9 +190,10 @@ enum tal_notify_type {
  * not called when this context is tal_free()d: TAL_NOTIFY_FREE is
  * considered sufficient for that case.
  *
- * TAL_NOTIFY_ADD_NOTIFIER/TAL_NOTIFIER_DEL_NOTIFIER are called when
- * a notifier is added or removed (not for this notifier): @info is the
- * callback.
+ * TAL_NOTIFY_ADD_NOTIFIER/TAL_NOTIFIER_DEL_NOTIFIER are called when a
+ * notifier is added or removed (not for this notifier): @info is the
+ * callback.  This is also called for tal_add_destructor and
+ * tal_del_destructor.
  */
 #define tal_add_notifier(ptr, types, callback)                         \
        tal_add_notifier_((ptr), (types),                               \
@@ -401,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 */