memleak: simplify API.

Mainly renaming.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2022-09-16 12:44:39 +09:30
parent fd71dfc7f7
commit 3380f559f9
29 changed files with 186 additions and 161 deletions

View File

@@ -927,7 +927,7 @@ static void wait_and_check_bitcoind(struct plugin *p)
#if DEVELOPER
static void memleak_mark_bitcoind(struct plugin *p, struct htable *memtable)
{
memleak_remove_region(memtable, bitcoind, sizeof(*bitcoind));
memleak_scan_obj(memtable, bitcoind);
}
#endif

View File

@@ -920,12 +920,12 @@ static struct command_result *json_commando_rune(struct command *cmd,
#if DEVELOPER
static void memleak_mark_globals(struct plugin *p, struct htable *memtable)
{
memleak_remove_region(memtable, outgoing_commands, tal_bytelen(outgoing_commands));
memleak_remove_region(memtable, incoming_commands, tal_bytelen(incoming_commands));
memleak_remove_region(memtable, master_rune, sizeof(*master_rune));
memleak_remove_htable(memtable, &usage_table.raw);
memleak_scan_obj(memtable, outgoing_commands);
memleak_scan_obj(memtable, incoming_commands);
memleak_scan_obj(memtable, master_rune);
memleak_scan_htable(memtable, &usage_table.raw);
if (rune_counter)
memleak_remove_region(memtable, rune_counter, sizeof(*rune_counter));
memleak_scan_obj(memtable, rune_counter);
}
#endif

View File

@@ -1084,8 +1084,8 @@ static void tell_lightningd_lease_rates(struct plugin *p,
#if DEVELOPER
static void memleak_mark(struct plugin *p, struct htable *memtable)
{
memleak_remove_region(memtable, &pending_opens, sizeof(pending_opens));
memleak_remove_region(memtable, current_policy, sizeof(*current_policy));
memleak_scan_list_head(memtable, &pending_opens);
memleak_scan_obj(memtable, current_policy);
}
#endif

View File

@@ -1350,16 +1350,16 @@ static void memleak_check(struct plugin *plugin, struct command *cmd)
{
struct htable *memtable;
memtable = memleak_find_allocations(tmpctx, cmd, cmd);
memtable = memleak_start(tmpctx, cmd, cmd);
/* Now delete plugin and anything it has pointers to. */
memleak_remove_region(memtable, plugin, sizeof(*plugin));
memleak_scan_obj(memtable, plugin);
/* Memleak needs some help to see into strmaps */
memleak_remove_strmap(memtable, &plugin->out_reqs);
memleak_scan_strmap(memtable, &plugin->out_reqs);
/* We know usage strings are referred to. */
memleak_remove_strmap(memtable, &cmd->plugin->usagemap);
memleak_scan_strmap(memtable, &cmd->plugin->usagemap);
if (plugin->mark_mem)
plugin->mark_mem(plugin, memtable);

View File

@@ -571,7 +571,7 @@ static struct command_result *json_listpays(struct command *cmd,
#if DEVELOPER
static void memleak_mark_payments(struct plugin *p, struct htable *memtable)
{
memleak_remove_region(memtable, &payments, sizeof(payments));
memleak_scan_list_head(memtable, &payments);
}
#endif

View File

@@ -615,8 +615,7 @@ done:
#if DEVELOPER
static void memleak_mark(struct plugin *p, struct htable *memtable)
{
memleak_remove_region(memtable, global_gossmap,
tal_bytelen(global_gossmap));
memleak_scan_obj(memtable, global_gossmap);
}
#endif

View File

@@ -570,7 +570,7 @@ static const struct plugin_command commands[] = {
#if DEVELOPER
static void mark_unreleased_txs(struct plugin *plugin, struct htable *memtable)
{
memleak_remove_region(memtable, &unreleased_txs, sizeof(unreleased_txs));
memleak_scan_list_head(memtable, &unreleased_txs);
}
#endif