+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, NULL);
+}
+
+bool tal_add_destructor2_(const tal_t *ctx, void (*destroy)(void *me, void *arg),
+ void *arg)
+{
+ tal_t *t = debug_tal(to_tal_hdr(ctx));
+ return add_notifier_property(t, TAL_NOTIFY_FREE|NOTIFY_IS_DESTRUCTOR
+ |NOTIFY_EXTRA_ARG,
+ (void *)destroy, arg);
+}
+
+/* We could support notifiers with an extra arg, but we didn't add to API */
+bool tal_add_notifier_(const tal_t *ctx, enum tal_notify_type types,
+ void (*callback)(tal_t *, enum tal_notify_type, void *))
+{
+ struct tal_hdr *t = debug_tal(to_tal_hdr_or_null(ctx));
+ struct notifier *n;
+
+ assert(types);
+ assert((types & ~(TAL_NOTIFY_FREE | TAL_NOTIFY_STEAL | TAL_NOTIFY_MOVE
+ | TAL_NOTIFY_RESIZE | TAL_NOTIFY_RENAME
+ | TAL_NOTIFY_ADD_CHILD | TAL_NOTIFY_DEL_CHILD
+ | TAL_NOTIFY_ADD_NOTIFIER
+ | TAL_NOTIFY_DEL_NOTIFIER)) == 0);
+
+ /* Don't call notifier about itself: set types after! */
+ n = add_notifier_property(t, 0, callback, NULL);
+ if (unlikely(!n))
+ return false;
+
+ if (notifiers)
+ notify(t, TAL_NOTIFY_ADD_NOTIFIER, callback, 0);
+
+ n->types = types;
+ if (types != TAL_NOTIFY_FREE)
+ notifiers++;
+ return true;
+}
+
+bool tal_del_notifier_(const tal_t *ctx,
+ void (*callback)(tal_t *, enum tal_notify_type, void *),
+ bool match_extra_arg, void *extra_arg)
+{
+ struct tal_hdr *t = debug_tal(to_tal_hdr_or_null(ctx));
+ enum tal_notify_type types;
+
+ types = del_notifier_property(t, callback, match_extra_arg, extra_arg);
+ if (types) {
+ notify(t, TAL_NOTIFY_DEL_NOTIFIER, callback, 0);
+ if (types != TAL_NOTIFY_FREE)
+ notifiers--;
+ return true;
+ }
+ return false;
+}
+
+bool tal_del_destructor_(const tal_t *ctx, void (*destroy)(void *me))
+{
+ return tal_del_notifier_(ctx, (void *)destroy, false, NULL);
+}
+
+bool tal_del_destructor2_(const tal_t *ctx, void (*destroy)(void *me, void *arg),
+ void *arg)