From 2f15c0fb5c0c325c4ffa13240be41e533a82329d Mon Sep 17 00:00:00 2001 From: John Darrington Date: Sun, 24 Jul 2011 11:11:20 +0200 Subject: [PATCH] Fix memory leak --- src/math/categoricals.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/math/categoricals.c b/src/math/categoricals.c index 67ca1e9a..f1bd0902 100644 --- a/src/math/categoricals.c +++ b/src/math/categoricals.c @@ -243,6 +243,29 @@ categoricals_dump (const struct categoricals *cat) void categoricals_destroy (struct categoricals *cat) { + struct variable_node *vn = NULL; + int i; + for (i = 0; i < cat->n_iap; ++i) + { + struct interaction_value *iv = NULL; + /* Interate over each interaction value, and unref any cases that we reffed */ + HMAP_FOR_EACH (iv, struct interaction_value, node, &cat->iap[i].ivmap) + { + case_unref (iv->ccase); + } + hmap_destroy (&cat->iap[i].ivmap); + } + + /* Interate over each variable and delete its value map */ + HMAP_FOR_EACH (vn, struct variable_node, node, &cat->varmap) + { + hmap_destroy (&vn->valmap); + } + + hmap_destroy (&cat->varmap); + + pool_destroy (cat->pool); + free (cat); } -- 2.30.2