common: add new_htable() macro to allocate, initialize and setup memleak coverage for any typed hash table.
What changed, and why it matters
This is a code cleanup change that introduces a helper macro to reduce repeated boilerplate when creating hash tables and registering them with the project's memory-leak detection tooling. It does not fix a known security bug, change protocol behavior, or alter access controls. The patch removes many manual memleak-registration calls and replaces them with a single macro that performs allocation, initialization, and registration together.
No security action required. Treat as normal code-quality refactoring. If auditing, verify that the `new_htable` macro's `assert((void *)raw == (void *)p)` assumption holds for all generated htable types and that no generated htable places `raw` at a non-zero offset, which would break memleak coverage.
Security signals we found
Refactoring of memory-leak detection registration only
No change to input parsing, cryptography, network handling, or authorization
No bug fix or vulnerability remediation described in commit message
Removal of manual memleak helpers in favor of centralized macro
Evidence from the diff
The commit adds new_htable(ctx, type) in common/memleak.h, which allocates a typed htable via tal(), calls type##_init(), asserts that the htable’s embedded raw member is at offset zero, and registers memleak_scan_htable as a helper. It then refactors 23 files to use this macro, removing per-type memleak helper functions and explicit memleak_scan_htable/memleak_add_helper calls. The change is purely structural: the same objects are still tracked by the memleak scanner, and no runtime security boundary is changed.
Changed components
common/memleak.hchanneld/full_channel.cconnectd/connectd.cgossipd/gossipd.clightningd/chaintopology.clightningd/lightningd.clightningd/memdump.clightningd/onchain_control.cplugins/askrene/askrene.cplugins/askrene/layer.cplugins/askrene/layer.hplugins/askrene/reserve.cplugins/askrene/reserve.hplugins/chanbackup.cplugins/channel_hint.cwallet/txfilter.cwallet/txfilter.hwallet/wallet.cwallet/wallet.hInspect captured patch +46 / −184
diff --git a/channeld/full_channel.c b/channeld/full_channel.c
index 9bf383db..eca0ee52 100644
--- a/channeld/full_channel.c
+++ b/channeld/full_channel.c
@@ -18,12 +18,6 @@
/* Needs to be at end, since it doesn't include its own hdrs */
#include "full_channel_error_names_gen.h"
-static void memleak_help_htlcmap(struct htable *memtable,
- struct htlc_map *htlcs)
-{
- memleak_scan_htable(memtable, &htlcs->raw);
-}
-
/* This is a dangerous thing! Because we apply HTLCs in many places
* in bulk, we can temporarily go negative. You must check balance_ok()
* at the end! */
@@ -114,11 +108,9 @@ struct channel *new_full_channel(const tal_t *ctx,
option_wumbo,
opener);
- if (channel) {
- channel->htlcs = tal(channel, struct htlc_map);
- htlc_map_init(channel->htlcs);
- memleak_add_helper(channel->htlcs, memleak_help_htlcmap);
- }
+ if (channel)
+ channel->htlcs = new_htable(channel, htlc_map);
+
return channel;
}
diff --git a/common/memleak.h b/common/memleak.h
index 0ff2dc5a..5ff91770 100644
--- a/common/memleak.h
+++ b/common/memleak.h
@@ -107,6 +107,18 @@ void memleak_scan_region(struct htable *memtable, const void *p, size_t len);
/* Objects inside this htable (which is opaque to memleak) are not leaks. */
void memleak_scan_htable(struct htable *memtable, const struct htable *ht);
+/* Allocate a htable, set up memleak scan automatically (assumes &p->raw == p) */
+#define new_htable(ctx, type) \
+ ({ \
+ const struct htable *raw; \
+ struct type *p = tal(ctx, struct type); \
+ type##_init(p); \
+ raw = &p->raw; \
+ assert((void *)raw == (void *)p); \
+ memleak_add_helper(raw, memleak_scan_htable); \
+ p; \
+ })
+
/* Objects inside this uintmap (which is opaque to memleak) are not leaks. */
#define memleak_scan_uintmap(memtable, umap) \
memleak_scan_intmap_(memtable, uintmap_unwrap_(umap))
diff --git a/connectd/connectd.c b/connectd/connectd.c
index edbd51ad..c6e06a58 100644
--- a/connectd/connectd.c
+++ b/connectd/connectd.c
@@ -2019,9 +2019,6 @@ static void dev_connect_memleak(struct daemon *daemon, const u8 *msg)
/* Now delete daemon and those which it has pointers to. */
memleak_scan_obj(memtable, daemon);
- memleak_scan_htable(memtable, &daemon->peers->raw);
- memleak_scan_htable(memtable, &daemon->scid_htable->raw);
- memleak_scan_htable(memtable, &daemon->important_ids->raw);
found_leak = dump_memleak(memtable, memleak_status_broken, NULL);
daemon_conn_send(daemon->master,
@@ -2435,14 +2432,6 @@ static struct io_plan *recv_gossip(struct io_conn *conn,
return daemon_conn_read_next(conn, daemon->gossipd);
}
-/*~ This is a hook used by the memleak code: it can't see pointers
- * inside hash tables, so we give it a hint here. */
-static void memleak_daemon_cb(struct htable *memtable, struct daemon *daemon)
-{
- memleak_scan_htable(memtable, &daemon->peers->raw);
- memleak_scan_htable(memtable, &daemon->connecting->raw);
-}
-
static void gossipd_failed(struct daemon_conn *gossipd)
{
status_failed(STATUS_FAIL_GOSSIP_IO, "gossipd exited?");
@@ -2462,14 +2451,13 @@ int main(int argc, char *argv[])
daemon = tal(NULL, struct daemon);
daemon->developer = developer;
daemon->connection_counter = 1;
- daemon->peers = tal(daemon, struct peer_htable);
+ /* htable_new is our helper which allocates a htable, initializes it
+ * and set up the memleak callback so our memleak code can see objects
+ * inside it */
+ daemon->peers = new_htable(daemon, peer_htable);
daemon->listeners = tal_arr(daemon, struct io_listener *, 0);
- peer_htable_init(daemon->peers);
- memleak_add_helper(daemon, memleak_daemon_cb);
- daemon->connecting = tal(daemon, struct connecting_htable);
- connecting_htable_init(daemon->connecting);
- daemon->important_ids = tal(daemon, struct important_id_htable);
- important_id_htable_init(daemon->important_ids);
+ daemon->connecting = new_htable(daemon, connecting_htable);
+ daemon->important_ids = new_htable(daemon, important_id_htable);
timers_init(&daemon->timers, time_mono());
daemon->gossmap_raw = NULL;
daemon->shutting_down = false;
@@ -2479,8 +2467,7 @@ int main(int argc, char *argv[])
daemon->dev_exhausted_fds = false;
/* We generally allow 1MB per second per peer, except for dev testing */
daemon->gossip_stream_limit = 1000000;
- daemon->scid_htable = tal(daemon, struct scid_htable);
- scid_htable_init(daemon->scid_htable);
+ daemon->scid_htable = new_htable(daemon, scid_htable);
/* stdin == control */
daemon->master = daemon_conn_new(daemon, STDIN_FILENO, recv_req, NULL,
diff --git a/gossipd/gossipd.c b/gossipd/gossipd.c
index 18166adb..a3661912 100644
--- a/gossipd/gossipd.c
+++ b/gossipd/gossipd.c
@@ -472,7 +472,6 @@ static void dev_gossip_memleak(struct daemon *daemon, const u8 *msg)
memleak_ptr(memtable, msg);
/* Now delete daemon and those which it has pointers to. */
memleak_scan_obj(memtable, daemon);
- memleak_scan_htable(memtable, &daemon->peers->raw);
dev_seeker_memleak(memtable, daemon->seeker);
gossmap_manage_memleak(memtable, daemon->gm);
@@ -625,8 +624,7 @@ int main(int argc, char *argv[])
daemon = tal(NULL, struct daemon);
daemon->developer = developer;
daemon->dev_gossip_time = NULL;
- daemon->peers = tal(daemon, struct peer_node_id_map);
- peer_node_id_map_init(daemon->peers);
+ daemon->peers = new_htable(daemon, peer_node_id_map);
daemon->deferred_txouts = tal_arr(daemon, struct short_channel_id, 0);
daemon->current_blockheight = 0; /* i.e. unknown */
diff --git a/lightningd/chaintopology.c b/lightningd/chaintopology.c
index 99e99205..9d85b8ce 100644
--- a/lightningd/chaintopology.c
+++ b/lightningd/chaintopology.c
@@ -1220,14 +1220,10 @@ struct chain_topology *new_topology(struct lightningd *ld, struct logger *log)
struct chain_topology *topo = tal(ld, struct chain_topology);
topo->ld = ld;
- topo->block_map = tal(topo, struct block_map);
- block_map_init(topo->block_map);
- topo->outgoing_txs = tal(topo, struct outgoing_tx_map);
- outgoing_tx_map_init(topo->outgoing_txs);
- topo->txwatches = tal(topo, struct txwatch_hash);
- txwatch_hash_init(topo->txwatches);
- topo->txowatches = tal(topo, struct txowatch_hash);
- txowatch_hash_init(topo->txowatches);
+ topo->block_map = new_htable(topo, block_map);
+ topo->outgoing_txs = new_htable(topo, outgoing_tx_map);
+ topo->txwatches = new_htable(topo, txwatch_hash);
+ topo->txowatches = new_htable(topo, txowatch_hash);
topo->log = log;
topo->bitcoind = new_bitcoind(topo, ld, log);
topo->poll_seconds = 30;
diff --git a/lightningd/lightningd.c b/lightningd/lightningd.c
index 8eb3acc9..2ce30d3f 100644
--- a/lightningd/lightningd.c
+++ b/lightningd/lightningd.c
@@ -186,42 +186,34 @@ static struct lightningd *new_lightningd(const tal_t *ctx)
* list attached to the channel structure itself, or even left them in
* the database rather than making an in-memory version. Obviously
* I was in a premature optimization mood when I wrote this: */
- ld->htlcs_in = tal(ld, struct htlc_in_map);
- htlc_in_map_init(ld->htlcs_in);
+ ld->htlcs_in = new_htable(ld, htlc_in_map);
/*~ Note also: we didn't need to use an allocation here! We could
* have simply made the `struct htlc_out_map` a member. But we
* override the htable allocation routines to use tal(), and they
* want a tal parent, so we always make our hash table a tallocated
* object. */
- ld->htlcs_out = tal(ld, struct htlc_out_map);
- htlc_out_map_init(ld->htlcs_out);
+ ld->htlcs_out = new_htable(ld, htlc_out_map);
/*~ This is the hash table of peers: converted from a
* linked-list as part of the 100k-peers project! */
- ld->peers = tal(ld, struct peer_node_id_map);
- peer_node_id_map_init(ld->peers);
+ ld->peers = new_htable(ld, peer_node_id_map);
/*~ And this was done at the same time, for db lookups at startup */
- ld->peers_by_dbid = tal(ld, struct peer_dbid_map);
- peer_dbid_map_init(ld->peers_by_dbid);
+ ld->peers_by_dbid = new_htable(ld, peer_dbid_map);
/*~ This speeds lookups for short_channel_ids to their channels. */
- ld->channels_by_scid = tal(ld, struct channel_scid_map);
- channel_scid_map_init(ld->channels_by_scid);
+ ld->channels_by_scid = new_htable(ld, channel_scid_map);
/*~ Coin movements in db are indexed by the channel dbid. */
- ld->channels_by_dbid = tal(ld, struct channel_dbid_map);
- channel_dbid_map_init(ld->channels_by_dbid);
+ ld->channels_by_dbid = new_htable(ld, channel_dbid_map);
/*~ For multi-part payments, we need to keep some incoming payments
* in limbo until we get all the parts, or we time them out. */
- ld->htlc_sets = tal(ld, struct htlc_set_map);
- htlc_set_map_init(ld->htlc_sets);
+ ld->htlc_sets = new_htable(ld, htlc_set_map);
/*~ We keep a map of closed channels. Mainly so we can respond to peers
* who talk to us about long-closed channels. */
- ld->closed_channels = tal(ld, struct closed_channel_map);
- closed_channel_map_init(ld->closed_channels);
+ ld->closed_channels = new_htable(ld, closed_channel_map);
/*~ We have a multi-entry log-book infrastructure: we define a 10MB log
* book to hold all the entries (and trims as necessary), and multiple
diff --git a/lightningd/memdump.c b/lightningd/memdump.c
index 2372ab0a..ec0c49ca 100644
--- a/lightningd/memdump.c
+++ b/lightningd/memdump.c
@@ -189,19 +189,6 @@ static bool lightningd_check_leaks(struct command *cmd)
memleak_ptr(memtable, cmd);
memleak_ignore_children(memtable, cmd);
- /* First delete known false positives. */
- memleak_scan_htable(memtable, &ld->topology->txwatches->raw);
- memleak_scan_htable(memtable, &ld->topology->txowatches->raw);
- memleak_scan_htable(memtable, &ld->topology->outgoing_txs->raw);
- memleak_scan_htable(memtable, &ld->htlcs_in->raw);
- memleak_scan_htable(memtable, &ld->htlcs_out->raw);
- memleak_scan_htable(memtable, &ld->htlc_sets->raw);
- memleak_scan_htable(memtable, &ld->peers->raw);
- memleak_scan_htable(memtable, &ld->peers_by_dbid->raw);
- memleak_scan_htable(memtable, &ld->channels_by_scid->raw);
- memleak_scan_htable(memtable, &ld->closed_channels->raw);
- wallet_memleak_scan(memtable, ld->wallet);
-
/* Now delete ld and those which it has pointers to. */
memleak_scan_obj(memtable, ld);
diff --git a/lightningd/onchain_control.c b/lightningd/onchain_control.c
index 09d5d896..192450e3 100644
--- a/lightningd/onchain_control.c
+++ b/lightningd/onchain_control.c
@@ -43,13 +43,6 @@ static bool replay_tx_eq_txid(const struct replay_tx *rtx,
HTABLE_DEFINE_NODUPS_TYPE(struct replay_tx, replay_tx_keyof, txid_hash, replay_tx_eq_txid,
replay_tx_hash);
-/* Helper for memleak detection */
-static void memleak_replay_tx_hash(struct htable *memtable,
- struct replay_tx_hash *replay_tx_hash)
-{
- memleak_scan_htable(memtable, &replay_tx_hash->raw);
-}
-
/* We dump all the known preimages when onchaind starts up. */
static void onchaind_tell_fulfill(struct channel *channel)
{
@@ -1898,11 +1891,8 @@ void onchaind_replay_channels(struct lightningd *ld)
channel_state_name(channel), blockheight);
/* We're in replay mode */
- channel->onchaind_replay_watches = tal(channel, struct replay_tx_hash);
+ channel->onchaind_replay_watches = new_htable(channel, replay_tx_hash);
channel->onchaind_replay_height = blockheight;
- replay_tx_hash_init(channel->onchaind_replay_watches);
- memleak_add_helper(channel->onchaind_replay_watches,
- memleak_replay_tx_hash);
onchaind_funding_spent(channel, tx, blockheight);
onchaind_replay(channel);
diff --git a/plugins/askrene/askrene.c b/plugins/askrene/askrene.c
index fff49c05..6e9b35a4 100644
--- a/plugins/askrene/askrene.c
+++ b/plugins/askrene/askrene.c
@@ -1291,13 +1291,6 @@ static const struct plugin_command commands[] = {
},
};
-static void askrene_markmem(struct plugin *plugin, struct htable *memtable)
-{
- struct askrene *askrene = get_askrene(plugin);
- layer_memleak_mark(askrene, memtable);
- reserve_memleak_mark(askrene, memtable);
-}
-
static const char *init(struct command *init_cmd,
const char *buf UNUSED, const jsmntok_t *config UNUSED)
{
@@ -1317,7 +1310,6 @@ static const char *init(struct command *init_cmd,
"{id:%}", JSON_SCAN(json_to_node_id, &askrene->my_id));
plugin_set_data(plugin, askrene);
- plugin_set_memleak_handler(plugin, askrene_markmem);
load_layers(askrene, init_cmd);
diff --git a/plugins/askrene/layer.c b/plugins/askrene/layer.c
index 281e32a0..4cbe657a 100644
--- a/plugins/askrene/layer.c
+++ b/plugins/askrene/layer.c
@@ -162,14 +162,10 @@ struct layer *new_temp_layer(const tal_t *ctx, struct askrene *askrene, const ch
l->askrene = askrene;
l->name = tal_strdup(l, name);
l->persistent = false;
- l->local_channels = tal(l, struct local_channel_hash);
- local_channel_hash_init(l->local_channels);
- l->local_updates = tal(l, struct local_update_hash);
- local_update_hash_init(l->local_updates);
- l->constraints = tal(l, struct constraint_hash);
- constraint_hash_init(l->constraints);
- l->biases = tal(l, struct bias_hash);
- bias_hash_init(l->biases);
+ l->local_channels = new_htable(l, local_channel_hash);
+ l->local_updates = new_htable(l, local_update_hash);
+ l->constraints = new_htable(l, constraint_hash);
+ l->biases = new_htable(l, bias_hash);
l->disabled_nodes = tal_arr(l, struct node_id, 0);
return l;
@@ -1162,14 +1158,3 @@ bool layer_disables_node(const struct layer *layer,
}
return false;
}
-
-void layer_memleak_mark(struct askrene *askrene, struct htable *memtable)
-{
- struct layer *l;
- list_for_each(&askrene->layers, l, list) {
- memleak_scan_htable(memtable, &l->constraints->raw);
- memleak_scan_htable(memtable, &l->local_channels->raw);
- memleak_scan_htable(memtable, &l->local_updates->raw);
- memleak_scan_htable(memtable, &l->biases->raw);
- }
-}
diff --git a/plugins/askrene/layer.h b/plugins/askrene/layer.h
index e9b06fd5..b93f228f 100644
--- a/plugins/askrene/layer.h
+++ b/plugins/askrene/layer.h
@@ -135,6 +135,4 @@ bool layer_disables_chan(const struct layer *layer, const struct short_channel_i
/* For explain_failure: did this layer disable this node? */
bool layer_disables_node(const struct layer *layer, const struct node_id *node);
-/* Scan for memleaks */
-void layer_memleak_mark(struct askrene *askrene, struct htable *memtable);
#endif /* LIGHTNING_PLUGINS_ASKRENE_LAYER_H */
diff --git a/plugins/askrene/reserve.c b/plugins/askrene/reserve.c
index 59457fc2..738577fc 100644
--- a/plugins/askrene/reserve.c
+++ b/plugins/askrene/reserve.c
@@ -37,9 +37,7 @@ HTABLE_DEFINE_DUPS_TYPE(struct reserve, reserve_scidd, hash_scidd,
struct reserve_htable *new_reserve_htable(const tal_t *ctx)
{
- struct reserve_htable *reserved = tal(ctx, struct reserve_htable);
- reserve_htable_init(reserved);
- return reserved;
+ return new_htable(ctx, reserve_htable);
}
void reserve_add(struct reserve_htable *reserved,
@@ -177,8 +175,3 @@ const char *fmt_reservations(const tal_t *ctx,
}
return ret;
}
-
-void reserve_memleak_mark(struct askrene *askrene, struct htable *memtable)
-{
- memleak_scan_htable(memtable, &askrene->reserved->raw);
-}
diff --git a/plugins/askrene/reserve.h b/plugins/askrene/reserve.h
index 1c9e71ea..868756ca 100644
--- a/plugins/askrene/reserve.h
+++ b/plugins/askrene/reserve.h
@@ -50,6 +50,4 @@ void json_add_reservations(struct json_stream *js,
const struct reserve_htable *reserved,
const char *fieldname);
-/* Scan for memleaks */
-void reserve_memleak_mark(struct askrene *askrene, struct htable *memtable);
#endif /* LIGHTNING_PLUGINS_ASKRENE_RESERVE_H */
diff --git a/plugins/chanbackup.c b/plugins/chanbackup.c
index de298ec3..4b4addf5 100644
--- a/plugins/chanbackup.c
+++ b/plugins/chanbackup.c
@@ -1037,10 +1037,8 @@ static void setup_backup_map(struct command *init_cmd,
const jsmntok_t *datastore, *t;
size_t i, total = 0;
- cb->backups = tal(cb, struct backup_map);
- backup_map_init(cb->backups);
- cb->peers = tal(cb, struct peer_map);
- peer_map_init(cb->peers);
+ cb->backups = new_htable(cb, backup_map);
+ cb->peers = new_htable(cb, peer_map);
json_out_start(params, NULL, '{');
json_out_start(params, "key", '[');
@@ -1081,14 +1079,6 @@ static void setup_backup_map(struct command *init_cmd,
"Loaded %zu stored backups for peers", total);
}
-static void chanbackup_mark_mem(struct plugin *plugin,
- struct htable *memtable)
-{
- const struct chanbackup *cb = chanbackup(plugin);
- memleak_scan_htable(memtable, &cb->backups->raw);
- memleak_scan_htable(memtable, &cb->peers->raw);
-}
-
static const char *init(struct command *init_cmd,
const char *buf UNUSED,
const jsmntok_t *config UNUSED)
@@ -1129,9 +1119,6 @@ static const char *init(struct command *init_cmd,
unlink_noerr("scb.tmp");
maybe_create_new_scb(init_cmd->plugin, scb_chan);
-
- plugin_set_memleak_handler(init_cmd->plugin,
- chanbackup_mark_mem);
return NULL;
}
diff --git a/plugins/channel_hint.c b/plugins/channel_hint.c
index cf431cb8..4862832d 100644
--- a/plugins/channel_hint.c
+++ b/plugins/channel_hint.c
@@ -24,12 +24,6 @@ bool channel_hint_eq(const struct channel_hint *a,
a->scid.dir == b->dir;
}
-static void memleak_help_channel_hint_map(struct htable *memtable,
- struct channel_hint_map *channel_hints)
-{
- memleak_scan_htable(memtable, &channel_hints->raw);
-}
-
void channel_hint_to_json(const char *name, const struct channel_hint *hint,
struct json_stream *dest)
{
@@ -212,9 +206,7 @@ struct channel_hint *channel_hint_from_json(const tal_t *ctx,
struct channel_hint_set *channel_hint_set_new(const tal_t *ctx)
{
struct channel_hint_set *set = tal(ctx, struct channel_hint_set);
- set->hints = tal(set, struct channel_hint_map);
- channel_hint_map_init(set->hints);
- memleak_add_helper(set->hints, memleak_help_channel_hint_map);
+ set->hints = new_htable(set, channel_hint_map);
return set;
}
diff --git a/wallet/test/run-chain_moves_duplicate-detect.c b/wallet/test/run-chain_moves_duplicate-detect.c
index 3a7134f7..88907005 100644
--- a/wallet/test/run-chain_moves_duplicate-detect.c
+++ b/wallet/test/run-chain_moves_duplicate-detect.c
@@ -157,10 +157,6 @@ struct invoices *invoices_new(const tal_t *ctx UNNEEDED,
struct wallet *wallet UNNEEDED,
struct timers *timers UNNEEDED)
{ fprintf(stderr, "invoices_new called!\n"); abort(); }
-/* Generated stub for memleak_scan_outpointfilter */
-void memleak_scan_outpointfilter(struct htable *memtable UNNEEDED,
- const struct outpointfilter *opf UNNEEDED)
-{ fprintf(stderr, "memleak_scan_outpointfilter called!\n"); abort(); }
/* Generated stub for new_channel */
struct channel *new_channel(struct peer *peer UNNEEDED, u64 dbid UNNEEDED,
/* NULL or stolen */
diff --git a/wallet/test/run-db.c b/wallet/test/run-db.c
index 1c71c426..81e816b7 100644
--- a/wallet/test/run-db.c
+++ b/wallet/test/run-db.c
@@ -165,10 +165,6 @@ struct invoices *invoices_new(const tal_t *ctx UNNEEDED,
void logv(struct logger *logger UNNEEDED, enum log_level level UNNEEDED, const struct node_id *node_id UNNEEDED,
bool call_notifier UNNEEDED, const char *fmt UNNEEDED, va_list ap UNNEEDED)
{ fprintf(stderr, "logv called!\n"); abort(); }
-/* Generated stub for memleak_scan_outpointfilter */
-void memleak_scan_outpointfilter(struct htable *memtable UNNEEDED,
- const struct outpointfilter *opf UNNEEDED)
-{ fprintf(stderr, "memleak_scan_outpointfilter called!\n"); abort(); }
/* Generated stub for new_channel */
struct channel *new_channel(struct peer *peer UNNEEDED, u64 dbid UNNEEDED,
/* NULL or stolen */
diff --git a/wallet/test/run-migrate_remove_chain_moves_duplicates.c b/wallet/test/run-migrate_remove_chain_moves_duplicates.c
index 62b46063..5e312a18 100644
--- a/wallet/test/run-migrate_remove_chain_moves_duplicates.c
+++ b/wallet/test/run-migrate_remove_chain_moves_duplicates.c
@@ -169,10 +169,6 @@ struct invoices *invoices_new(const tal_t *ctx UNNEEDED,
void logv(struct logger *logger UNNEEDED, enum log_level level UNNEEDED, const struct node_id *node_id UNNEEDED,
bool call_notifier UNNEEDED, const char *fmt UNNEEDED, va_list ap UNNEEDED)
{ fprintf(stderr, "logv called!\n"); abort(); }
-/* Generated stub for memleak_scan_outpointfilter */
-void memleak_scan_outpointfilter(struct htable *memtable UNNEEDED,
- const struct outpointfilter *opf UNNEEDED)
-{ fprintf(stderr, "memleak_scan_outpointfilter called!\n"); abort(); }
/* Generated stub for migrate_from_account_db */
void migrate_from_account_db(struct lightningd *ld UNNEEDED, struct db *db UNNEEDED)
{ fprintf(stderr, "migrate_from_account_db called!\n"); abort(); }
diff --git a/wallet/test/run-wallet.c b/wallet/test/run-wallet.c
index c24382c1..c616710a 100644
--- a/wallet/test/run-wallet.c
+++ b/wallet/test/run-wallet.c
@@ -443,10 +443,6 @@ void lockin_complete(struct channel *channel UNNEEDED,
void logv(struct logger *logger UNNEEDED, enum log_level level UNNEEDED, const struct node_id *node_id UNNEEDED,
bool call_notifier UNNEEDED, const char *fmt UNNEEDED, va_list ap UNNEEDED)
{ fprintf(stderr, "logv called!\n"); abort(); }
-/* Generated stub for memleak_scan_outpointfilter */
-void memleak_scan_outpointfilter(struct htable *memtable UNNEEDED,
- const struct outpointfilter *opf UNNEEDED)
-{ fprintf(stderr, "memleak_scan_outpointfilter called!\n"); abort(); }
/* Generated stub for new_channel_mvt_invoice_hin */
struct channel_coin_mvt *new_channel_mvt_invoice_hin(const tal_t *ctx UNNEEDED,
const struct htlc_in *hin UNNEEDED,
diff --git a/wallet/txfilter.c b/wallet/txfilter.c
index a8b32db6..e3249acc 100644
--- a/wallet/txfilter.c
+++ b/wallet/txfilter.c
@@ -126,12 +126,6 @@ void outpointfilter_remove(struct outpointfilter *of,
struct outpointfilter *outpointfilter_new(tal_t *ctx)
{
struct outpointfilter *opf = tal(ctx, struct outpointfilter);
- opf->set = tal(opf, struct outpointset);
- outpointset_init(opf->set);
+ opf->set = new_htable(opf, outpointset);
return opf;
}
-
-void memleak_scan_outpointfilter(struct htable *memtable, const struct outpointfilter *opf)
-{
- memleak_scan_htable(memtable, &opf->set->raw);
-}
diff --git a/wallet/txfilter.h b/wallet/txfilter.h
index c9152bff..2e72b68e 100644
--- a/wallet/txfilter.h
+++ b/wallet/txfilter.h
@@ -64,9 +64,6 @@ bool outpointfilter_matches(struct outpointfilter *of,
void outpointfilter_remove(struct outpointfilter *of,
const struct bitcoin_outpoint *outpoint);
-void memleak_scan_outpointfilter(struct htable *memtable,
- const struct outpointfilter *opf);
-
/* Useful for other callers */
size_t scriptpubkey_hash(const u8 *out);
diff --git a/wallet/wallet.c b/wallet/wallet.c
index 363c083d..50d9ac7d 100644
--- a/wallet/wallet.c
+++ b/wallet/wallet.c
@@ -176,8 +176,7 @@ static void our_addresses_add_for_index(struct wallet *w, u32 i)
static void our_addresses_init(struct wallet *w)
{
w->our_addresses_maxindex = 0;
- w->our_addresses = tal(w, struct wallet_address_htable);
- wallet_address_htable_init(w->our_addresses);
+ w->our_addresses = new_htable(w, wallet_address_htable);
our_addresses_add_for_index(w, w->our_addresses_maxindex);
}
@@ -6913,13 +6912,6 @@ struct local_anchor_info *wallet_get_local_anchors(const tal_t *ctx,
return anchors;
}
-void wallet_memleak_scan(struct htable *memtable, const struct wallet *w)
-{
- memleak_scan_outpointfilter(memtable, w->utxoset_outpoints);
- memleak_scan_outpointfilter(memtable, w->owned_outpoints);
- memleak_scan_htable(memtable, &w->our_addresses->raw);
-}
-
struct issued_address_type *wallet_list_addresses(const tal_t *ctx, struct wallet *wallet,
u64 liststart, const u32 *listlimit)
{
diff --git a/wallet/wallet.h b/wallet/wallet.h
index 7eb1a51c..56f61b28 100644
--- a/wallet/wallet.h
+++ b/wallet/wallet.h
@@ -1929,8 +1929,4 @@ void wallet_datastore_save_payment_description(struct db *db,
void migrate_setup_coinmoves(struct lightningd *ld, struct db *db);
void migrate_remove_chain_moves_duplicates(struct lightningd *ld, struct db *db);
-/**
- * wallet_memleak_scan - Check for memleaks in wallet.
- */
-void wallet_memleak_scan(struct htable *memtable, const struct wallet *w);
#endif /* LIGHTNING_WALLET_WALLET_H */
Why this scored 18/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.