From 7f192958aefb6bf4d257a1760fcf349af97e2347 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Wed, 24 May 2023 17:29:32 -0700 Subject: [PATCH] libsysprof-analyze: free callgraph node tree on finalize --- src/libsysprof-analyze/sysprof-callgraph.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/libsysprof-analyze/sysprof-callgraph.c b/src/libsysprof-analyze/sysprof-callgraph.c index a3bf441f..9280fab9 100644 --- a/src/libsysprof-analyze/sysprof-callgraph.c +++ b/src/libsysprof-analyze/sysprof-callgraph.c @@ -80,6 +80,23 @@ list_model_iface_init (GListModelInterface *iface) G_DEFINE_FINAL_TYPE_WITH_CODE (SysprofCallgraph, sysprof_callgraph, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE (G_TYPE_LIST_MODEL, list_model_iface_init)) +static void +sysprof_callgraph_node_free (SysprofCallgraphNode *node, + gboolean free_self) +{ + SysprofCallgraphNode *iter = node->children; + + while (iter) + { + SysprofCallgraphNode *to_free = iter; + iter = iter->next; + sysprof_callgraph_node_free (to_free, TRUE); + } + + if (free_self) + g_free (node); +} + static void sysprof_callgraph_dispose (GObject *object) { @@ -107,6 +124,8 @@ sysprof_callgraph_finalize (GObject *object) g_clear_object (&self->traceables); g_clear_object (&self->everything); + sysprof_callgraph_node_free (&self->root, FALSE); + G_OBJECT_CLASS (sysprof_callgraph_parent_class)->finalize (object); }