tal: support destructors with an extra argument.
authorRusty Russell <rusty@rustcorp.com.au>
Thu, 29 Dec 2016 04:33:19 +0000 (15:03 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Thu, 29 Dec 2016 23:12:44 +0000 (09:42 +1030)
commit58277ab6c8b4dd6bb66638b88bd8505f46fdcb07
tree6a401b83fe15fefda5cbeb9cd4c3b2e19fc35a3f
parent31c816a6a9a2037d8860d56814835d9ac488d52f
tal: support destructors with an extra argument.

There are several times I've wanted an extra arg to the destructor, and had
to embed it in the thing destroyed.  It's more efficient to put it into
tal itself (since it allocates space anyway), but we make it conditional
on a flag to avoid bloating every destructor.

The infrastructure makes it easier to add an extra arg to the general
notifiers later if we want.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ccan/tal/tal.c
ccan/tal/tal.h
ccan/tal/test/run-destructor2.c [new file with mode: 0644]