diff --git a/common/setup.c b/common/setup.c index 46879e6e1..8ae05bf43 100644 --- a/common/setup.c +++ b/common/setup.c @@ -1,6 +1,7 @@ #include "config.h" #include #include +#include #include #include #include @@ -24,6 +25,15 @@ static struct wally_operations wally_tal_ops = { .free_fn = wally_free, }; +static void *htable_tal(struct htable *ht, size_t len) +{ + return tal_arrz(ht, u8, len); +} + +static void htable_tal_free(struct htable *ht, void *p) +{ + tal_free(p); +} void common_setup(const char *argv0) { @@ -47,6 +57,9 @@ void common_setup(const char *argv0) errx(1, "Error setting libwally operations: %i", wally_ret); secp256k1_ctx = wally_get_secp_context(); + /* Make htable* use tal for the tables themselves. */ + htable_set_allocator(htable_tal, htable_tal_free); + setup_tmpctx(); } diff --git a/connectd/test/run-gossip_rcvd_filter.c b/connectd/test/run-gossip_rcvd_filter.c index dc1f51aba..17810ac3c 100644 --- a/connectd/test/run-gossip_rcvd_filter.c +++ b/connectd/test/run-gossip_rcvd_filter.c @@ -172,9 +172,14 @@ int main(int argc, char *argv[]) assert(htable_count(f->cur) == 0); assert(htable_count(f->old) == 0); - /* They should have no children, and f should only have 2. */ - assert(!tal_first(f->cur)); - assert(!tal_first(f->old)); + /* They should have no children (except htable contents for one!), and + * f should only have 2. */ + if (tal_first(f->cur) == NULL) + assert(tal_first(f->old) == f->old->table); + else { + assert(tal_first(f->cur) == f->cur->table); + assert(tal_first(f->old) == NULL); + } assert((tal_first(f) == f->cur && tal_next(f->cur) == f->old