(2,3)
| 2007 | } |
| 2008 | |
| 2009 | static void PRINTF_FMT(2,3) log_memleak(struct plugin *plugin, const char *fmt, ...) |
| 2010 | { |
| 2011 | va_list ap; |
| 2012 | |
| 2013 | va_start(ap, fmt); |
| 2014 | plugin_logv(plugin, LOG_BROKEN, fmt, ap); |
| 2015 | va_end(ap); |
| 2016 | } |
| 2017 | |
| 2018 | static void memleak_check(struct plugin *plugin, struct command *cmd) |
| 2019 | { |
| 2020 | struct htable *memtable; |
| 2021 | |
| 2022 | memtable = memleak_start(tmpctx); |
| 2023 | |
| 2024 | /* cmd in use right now */ |
| 2025 | memleak_ptr(memtable, cmd); |
| 2026 | memleak_ignore_children(memtable, cmd); |
| 2027 | |
| 2028 | /* Now delete plugin and anything it has pointers to. */ |
| 2029 | memleak_scan_obj(memtable, plugin); |
| 2030 | |
| 2031 | /* Memleak needs some help to see into strmaps */ |
| 2032 | memleak_scan_strmap(memtable, &plugin->out_reqs); |
| 2033 | |
| 2034 | /* We know usage strings are referred to. */ |
| 2035 | memleak_scan_strmap(memtable, &cmd->plugin->usagemap); |
| 2036 | |
| 2037 | if (plugin->mark_mem) |
| 2038 | plugin->mark_mem(plugin, memtable); |
| 2039 | |
| 2040 | dump_memleak(memtable, log_memleak, plugin); |
| 2041 | } |
| 2042 | |
| 2043 | void plugin_set_memleak_handler(struct plugin *plugin, |
| 2044 | void (*mark_mem)(struct plugin *plugin, |
no test coverage detected