From: John Darrington Date: Sun, 24 Jul 2011 09:11:20 +0000 (+0200) Subject: Fix memory leak X-Git-Tag: v0.7.9~186 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2f15c0fb5c0c325c4ffa13240be41e533a82329d;p=pspp-builds.git Fix memory leak --- 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); }