From: John Darrington Date: Thu, 7 Jul 2011 10:14:29 +0000 (+0200) Subject: GLM: Fix memory leaks X-Git-Tag: v0.7.9~200 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=96c27d81b9e1161537ce3591c25cb38ae9b6698e;p=pspp-builds.git GLM: Fix memory leaks --- diff --git a/src/language/stats/glm.c b/src/language/stats/glm.c index 4ba93150..ba978c0a 100644 --- a/src/language/stats/glm.c +++ b/src/language/stats/glm.c @@ -63,7 +63,7 @@ struct glm_spec const struct variable **design_vars; size_t n_interactions; - const struct interaction **interactions; + struct interaction **interactions; enum mv_class exclude; @@ -104,6 +104,7 @@ static bool parse_design_spec (struct lexer *lexer, struct glm_spec *glm); int cmd_glm (struct lexer *lexer, struct dataset *ds) { + int i; struct const_var_set *factors = NULL; struct glm_spec glm; bool design = false; @@ -293,8 +294,11 @@ cmd_glm (struct lexer *lexer, struct dataset *ds) const_var_set_destroy (factors); free (glm.factor_vars); + for (i = 0 ; i < glm.n_interactions; ++i) + interaction_destroy (glm.interactions[i]); free (glm.interactions); free (glm.dep_vars); + free (glm.design_vars); return CMD_SUCCESS; @@ -303,8 +307,12 @@ error: const_var_set_destroy (factors); free (glm.factor_vars); + for (i = 0 ; i < glm.n_interactions; ++i) + interaction_destroy (glm.interactions[i]); + free (glm.interactions); free (glm.dep_vars); + free (glm.design_vars); return CMD_FAILURE; } diff --git a/src/math/categoricals.c b/src/math/categoricals.c index 58015c90..a3078d36 100644 --- a/src/math/categoricals.c +++ b/src/math/categoricals.c @@ -125,7 +125,17 @@ categoricals_destroy ( struct categoricals *cat) if (cat != NULL) { for (i = 0 ; i < cat->n_vp; ++i) - hmap_destroy (&cat->vp[i].map); + { + struct hmap *map = &cat->vp[i].map; + struct value_node *nn; + + HMAP_FOR_EACH (nn, struct value_node, node, map) + { + case_unref (nn->ccase); + } + + hmap_destroy (map); + } pool_destroy (cat->pool); free (cat);