all: no longer need to call htable_clear to free htable contents.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2023-01-12 11:43:14 +10:30
parent f07e37018d
commit 5dfcd15782
11 changed files with 0 additions and 46 deletions

View File

@ -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;
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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);
}

View File

@ -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

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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;
}