(1,2)
| 1384 | /* Hack since we have no extra ptr to log_memleak */ |
| 1385 | static struct plugin *memleak_plugin; |
| 1386 | static void PRINTF_FMT(1,2) log_memleak(const char *fmt, ...) |
| 1387 | { |
| 1388 | va_list ap; |
| 1389 | |
| 1390 | va_start(ap, fmt); |
| 1391 | plugin_logv(memleak_plugin, LOG_BROKEN, fmt, ap); |
| 1392 | va_end(ap); |
| 1393 | } |
| 1394 | |
| 1395 | static void memleak_check(struct plugin *plugin, struct command *cmd) |
| 1396 | { |
| 1397 | struct htable *memtable; |
| 1398 | |
| 1399 | memtable = memleak_start(tmpctx); |
| 1400 | |
| 1401 | /* cmd in use right now */ |
| 1402 | memleak_ptr(memtable, cmd); |
| 1403 | memleak_ignore_children(memtable, cmd); |
| 1404 | |
| 1405 | /* Now delete plugin and anything it has pointers to. */ |
| 1406 | memleak_scan_obj(memtable, plugin); |
| 1407 | |
| 1408 | /* Memleak needs some help to see into strmaps */ |
| 1409 | memleak_scan_strmap(memtable, &plugin->out_reqs); |
| 1410 | |
| 1411 | /* We know usage strings are referred to. */ |
| 1412 | memleak_scan_strmap(memtable, &cmd->plugin->usagemap); |
| 1413 | |
| 1414 | if (plugin->mark_mem) |
| 1415 | plugin->mark_mem(plugin, memtable); |
| 1416 | |
| 1417 | memleak_plugin = plugin; |
| 1418 | dump_memleak(memtable, log_memleak); |
| 1419 | } |
| 1420 | |
| 1421 | void plugin_set_memleak_handler(struct plugin *plugin, |
| 1422 | void (*mark_mem)(struct plugin *plugin, |
no test coverage detected