* @p: NULL, or tal allocated object to free.
*
* This calls the destructors for p (if any), then does the same for all its
- * children (recursively) before finally freeing the memory.
+ * children (recursively) before finally freeing the memory. It returns
+ * NULL, for convenience.
*
* Note: errno is preserved by this call.
*
* Example:
- * tal_free(p);
+ * p = tal_free(p);
*/
-void tal_free(const tal_t *p);
+void *tal_free(const tal_t *p);
/**
* tal_arr - allocate an array of objects.
#define tal_add_destructor(ptr, function) \
tal_add_destructor_((ptr), typesafe_cb(void, void *, (function), (ptr)))
+/**
+ * tal_del_destructor - remove a destructor callback function.
+ * @ptr: The tal allocated object.
+ * @function: the function to call before it's freed.
+ *
+ * If @function has not been successfully added as a destructor, this returns
+ * false.
+ */
+#define tal_del_destructor(ptr, function) \
+ tal_del_destructor_((ptr), typesafe_cb(void, void *, (function), (ptr)))
+
/**
* tal_set_name - attach a name to a tal pointer.
* @ptr: The tal allocated object.
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));
#endif /* CCAN_TAL_H */