mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-05 22:24:25 +01:00
memleak: don't require a root pointer.
We can just track everything from NULL (the ultimate parent) down. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
aa62d79db2
commit
8733015836
@@ -247,14 +247,22 @@ static void add_backtrace(tal_t *parent UNUSED, enum tal_notify_type type UNNEED
|
||||
tal_add_notifier(child, TAL_NOTIFY_ADD_CHILD, add_backtrace);
|
||||
}
|
||||
|
||||
void memleak_init(const tal_t *root)
|
||||
static void add_backtrace_notifiers(const tal_t *root)
|
||||
{
|
||||
tal_add_notifier(root, TAL_NOTIFY_ADD_CHILD, add_backtrace);
|
||||
|
||||
for (tal_t *i = tal_first(root); i; i = tal_next(i))
|
||||
add_backtrace_notifiers(i);
|
||||
}
|
||||
|
||||
void memleak_init(void)
|
||||
{
|
||||
assert(!notleaks);
|
||||
notleaks = tal_arr(NULL, const void *, 0);
|
||||
notleak_children = tal_arr(notleaks, bool, 0);
|
||||
|
||||
if (backtrace_state)
|
||||
tal_add_notifier(root, TAL_NOTIFY_ADD_CHILD, add_backtrace);
|
||||
add_backtrace_notifiers(NULL);
|
||||
}
|
||||
|
||||
void memleak_cleanup(void)
|
||||
|
||||
@@ -22,8 +22,8 @@ void *notleak_(const void *ptr, bool plus_children);
|
||||
|
||||
struct htable;
|
||||
|
||||
/* Initialize memleak detection, with this as the root */
|
||||
void memleak_init(const tal_t *root);
|
||||
/* Initialize memleak detection */
|
||||
void memleak_init(void);
|
||||
|
||||
/* Free memleak detection. */
|
||||
void memleak_cleanup(void);
|
||||
|
||||
@@ -54,7 +54,7 @@ static struct lightningd *new_lightningd(const tal_t *ctx)
|
||||
ld->dev_allow_localhost = false;
|
||||
|
||||
if (getenv("LIGHTNINGD_DEV_MEMLEAK"))
|
||||
memleak_init(ld);
|
||||
memleak_init();
|
||||
#endif
|
||||
|
||||
list_head_init(&ld->peers);
|
||||
|
||||
Reference in New Issue
Block a user