+ tal_t *t = debug_tal(to_tal_hdr(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);
+ 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 *))
+{
+ struct tal_hdr *t = debug_tal(to_tal_hdr(ctx));
+ enum tal_notify_type types;
+
+ types = del_notifier_property(t, callback);
+ 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);