1 /* MIT (BSD) license - see LICENSE file for details */
2 #include <ccan/tal/autoptr/autoptr.h>
8 static void autonull_remove(struct autonull *a);
9 static void autonull_null_out(tal_t *p UNNEEDED, struct autonull *a)
12 tal_del_destructor(a, autonull_remove);
17 static void autonull_remove(struct autonull *a)
19 /* Don't NULL us out now. */
20 tal_del_destructor2(*a->pp, autonull_null_out, a);
23 struct autonull *autonull_set_ptr_(const tal_t *ctx, void *pp, const tal_t *p)
25 struct autonull *a = tal(ctx, struct autonull);
29 /* If p is freed, NULL out a->pp */
30 tal_add_destructor2(*a->pp, autonull_null_out, a);
32 /* If they free autonull, it removes other destructor. */
33 tal_add_destructor(a, autonull_remove);