diff --git a/channeld/full_channel.c b/channeld/full_channel.c index 0395aa180..2d7814b75 100644 --- a/channeld/full_channel.c +++ b/channeld/full_channel.c @@ -120,7 +120,6 @@ struct channel *new_full_channel(const tal_t *ctx, channel->htlcs = tal(channel, struct htlc_map); htlc_map_init(channel->htlcs); memleak_add_helper(channel->htlcs, memleak_help_htlcmap); - tal_add_destructor(channel->htlcs, htlc_map_clear); } return channel; } diff --git a/common/gossmap.c b/common/gossmap.c index 92bbaf59d..af541169a 100644 --- a/common/gossmap.c +++ b/common/gossmap.c @@ -699,8 +699,6 @@ static void destroy_map(struct gossmap *map) { if (map->mmap) munmap(map->mmap, map->map_size); - chanidx_htable_clear(map->channels); - nodeidx_htable_clear(map->nodes); for (size_t i = 0; i < tal_count(map->node_arr); i++) free(map->node_arr[i].chan_idxs); diff --git a/common/memleak.c b/common/memleak.c index ba78029ea..9e778c28d 100644 --- a/common/memleak.c +++ b/common/memleak.c @@ -319,7 +319,6 @@ struct htable *memleak_start(const tal_t *ctx) call_memleak_helpers(memtable, NULL); } - tal_add_destructor(memtable, htable_clear); return memtable; } diff --git a/connectd/gossip_rcvd_filter.c b/connectd/gossip_rcvd_filter.c index 1d7f64646..a0e9b6b53 100644 --- a/connectd/gossip_rcvd_filter.c +++ b/connectd/gossip_rcvd_filter.c @@ -21,17 +21,11 @@ static size_t rehash(const void *key, void *unused) return ptr2int(key); } -static void destroy_msg_map(struct htable *ht) -{ - htable_clear(ht); -} - static struct htable *new_msg_map(const tal_t *ctx) { struct htable *ht = tal(ctx, struct htable); htable_init(ht, rehash, NULL); - tal_add_destructor(ht, destroy_msg_map); return ht; } diff --git a/gossipd/gossip_store.c b/gossipd/gossip_store.c index e1f781b45..b1e2ffebc 100644 --- a/gossipd/gossip_store.c +++ b/gossipd/gossip_store.c @@ -407,11 +407,6 @@ static void move_broadcast(struct offmap *offmap, offmap_del(offmap, omap); } -static void destroy_offmap(struct offmap *offmap) -{ - offmap_clear(offmap); -} - /** * Rewrite the on-disk gossip store, compacting it along the way * @@ -453,7 +448,6 @@ bool gossip_store_compact(struct gossip_store *gs) /* Walk old file, copy everything and remember new offsets. */ offmap = tal(tmpctx, struct offmap); offmap_init_sized(offmap, gs->count); - tal_add_destructor(offmap, destroy_offmap); /* Start by writing all channel announcements and updates. */ off = 1; diff --git a/gossipd/routing.c b/gossipd/routing.c index a8790b3e9..0751f15ce 100644 --- a/gossipd/routing.c +++ b/gossipd/routing.c @@ -127,7 +127,6 @@ static struct node_map *new_node_map(const tal_t *ctx) { struct node_map *map = tal(ctx, struct node_map); node_map_init(map); - tal_add_destructor(map, node_map_clear); return map; } @@ -204,9 +203,6 @@ static void destroy_routing_state(struct routing_state *rstate) chan; chan = uintmap_after(&rstate->chanmap, &idx)) free_chan(rstate, chan); - - /* Free up our htables */ - pending_cannouncement_map_clear(rstate->pending_cannouncements); } /* We don't check this when loading from the gossip_store: that would break @@ -356,10 +352,6 @@ static void destroy_node(struct node *node, struct routing_state *rstate) /* These remove themselves from chans[]. */ while ((c = first_chan(node, &i)) != NULL) free_chan(rstate, c); - - /* Free htable if we need. */ - if (node_uses_chan_map(node)) - chan_map_clear(node->chan_map); } struct node *get_node(struct routing_state *rstate, @@ -2077,8 +2069,6 @@ void remove_all_gossip(struct routing_state *rstate) * manually. */ while ((n = node_map_first(rstate->nodes, &nit)) != NULL) { tal_del_destructor2(n, destroy_node, rstate); - if (node_uses_chan_map(n)) - chan_map_clear(n->chan_map); node_map_del(rstate->nodes, n); tal_free(n); } diff --git a/lightningd/lightningd.c b/lightningd/lightningd.c index 0951ed6cf..65d3966b1 100644 --- a/lightningd/lightningd.c +++ b/lightningd/lightningd.c @@ -1259,10 +1259,6 @@ stop: /* Now close database */ ld->wallet->db = tal_free(ld->wallet->db); - /* Clean our our HTLC maps, since they use malloc. */ - htlc_in_map_clear(ld->htlcs_in); - htlc_out_map_clear(ld->htlcs_out); - remove(ld->pidfile); /* FIXME: pay can have children off tmpctx which unlink from diff --git a/lightningd/peer_htlcs.c b/lightningd/peer_htlcs.c index beb92fb3e..0ab918db9 100644 --- a/lightningd/peer_htlcs.c +++ b/lightningd/peer_htlcs.c @@ -2824,7 +2824,6 @@ void htlcs_resubmit(struct lightningd *ld, } /* Don't leak memory! */ - htlc_in_map_clear(unconnected_htlcs_in); tal_free(unconnected_htlcs_in); } diff --git a/plugins/pay.c b/plugins/pay.c index 454e7c4b2..e5392efbb 100644 --- a/plugins/pay.c +++ b/plugins/pay.c @@ -533,7 +533,6 @@ static struct command_result *listsendpays_done(struct command *cmd, assert(pm != NULL); add_new_entry(ret, buf, pm); } - pay_map_clear(pay_map); json_array_end(ret); return command_finished(cmd, ret); } diff --git a/wallet/test/run-wallet.c b/wallet/test/run-wallet.c index d757f67a0..e470a61e5 100644 --- a/wallet/test/run-wallet.c +++ b/wallet/test/run-wallet.c @@ -1850,8 +1850,6 @@ static bool test_htlc_crud(struct lightningd *ld, const tal_t *ctx) * twisted */ tal_free(hin); tal_free(hout); - htlc_in_map_clear(htlcs_in); - htlc_out_map_clear(htlcs_out); return true; } diff --git a/wallet/txfilter.c b/wallet/txfilter.c index c801da7fc..97ac35a88 100644 --- a/wallet/txfilter.c +++ b/wallet/txfilter.c @@ -52,16 +52,10 @@ struct outpointfilter { struct outpointset *set; }; -static void destroy_txfilter(struct txfilter *filter) -{ - scriptpubkeyset_clear(&filter->scriptpubkeyset); -} - struct txfilter *txfilter_new(const tal_t *ctx) { struct txfilter *filter = tal(ctx, struct txfilter); scriptpubkeyset_init(&filter->scriptpubkeyset); - tal_add_destructor(filter, destroy_txfilter); return filter; } @@ -123,16 +117,10 @@ void outpointfilter_remove(struct outpointfilter *of, outpointset_del(of->set, outpoint); } -static void destroy_outpointfilter(struct outpointfilter *opf) -{ - outpointset_clear(opf->set); -} - struct outpointfilter *outpointfilter_new(tal_t *ctx) { struct outpointfilter *opf = tal(ctx, struct outpointfilter); opf->set = tal(opf, struct outpointset); outpointset_init(opf->set); - tal_add_destructor(opf, destroy_outpointfilter); return opf; }