mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-21 14:24:09 +01:00
libplugin: let plugins add annotations to memleak.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> mar
This commit is contained in:
parent
dd65a9150a
commit
b82e5be6e1
2 changed files with 25 additions and 0 deletions
|
@ -99,6 +99,11 @@ struct plugin {
|
|||
|
||||
const char **notif_topics;
|
||||
size_t num_notif_topics;
|
||||
|
||||
#if DEVELOPER
|
||||
/* Lets them remove ptrs from leak detection. */
|
||||
void (*mark_mem)(struct plugin *plugin, struct htable *memtable);
|
||||
#endif
|
||||
};
|
||||
|
||||
/* command_result is mainly used as a compile-time check to encourage you
|
||||
|
@ -1197,9 +1202,19 @@ static void memleak_check(struct plugin *plugin, struct command *cmd)
|
|||
/* We know usage strings are referred to. */
|
||||
memleak_remove_strmap(memtable, &cmd->plugin->usagemap);
|
||||
|
||||
if (plugin->mark_mem)
|
||||
plugin->mark_mem(plugin, memtable);
|
||||
|
||||
memleak_plugin = plugin;
|
||||
dump_memleak(memtable, log_memleak);
|
||||
}
|
||||
|
||||
void plugin_set_memleak_handler(struct plugin *plugin,
|
||||
void (*mark_mem)(struct plugin *plugin,
|
||||
struct htable *memtable))
|
||||
{
|
||||
plugin->mark_mem = mark_mem;
|
||||
}
|
||||
#endif /* DEVELOPER */
|
||||
|
||||
static void ld_command_handle(struct plugin *plugin,
|
||||
|
@ -1498,6 +1513,9 @@ static struct plugin *new_plugin(const tal_t *ctx,
|
|||
tal_arr_expand(&p->opts, o);
|
||||
}
|
||||
|
||||
#if DEVELOPER
|
||||
p->mark_mem = NULL;
|
||||
#endif
|
||||
return p;
|
||||
}
|
||||
|
||||
|
|
|
@ -342,4 +342,11 @@ struct createonion_response *json_to_createonion_response(const tal_t *ctx,
|
|||
struct route_hop *json_to_route(const tal_t *ctx, const char *buffer,
|
||||
const jsmntok_t *toks);
|
||||
|
||||
#if DEVELOPER
|
||||
struct htable;
|
||||
void plugin_set_memleak_handler(struct plugin *plugin,
|
||||
void (*mark_mem)(struct plugin *plugin,
|
||||
struct htable *memtable));
|
||||
#endif /* DEVELOPER */
|
||||
|
||||
#endif /* LIGHTNING_PLUGINS_LIBPLUGIN_H */
|
||||
|
|
Loading…
Add table
Reference in a new issue