Fix memory leaks in Kruskal-Wallis test
authorJohn Darrington <john@darrington.wattle.id.au>
Tue, 12 Oct 2010 08:22:07 +0000 (10:22 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Tue, 12 Oct 2010 08:22:07 +0000 (10:22 +0200)
src/language/stats/kruskal-wallis.c

index 420b1a038d89f33cac8c6ce8fb5ca9a1aab7dcf7..63ede78a34377c0a9d5bdcf460922a736af5379a 100644 (file)
@@ -203,6 +203,17 @@ kruskal_wallis_execute (const struct dataset *ds,
   show_ranks_box (nst, kw, total_n_groups);
   show_sig_box (nst, kw);
 
+  for (i = 0 ; i < nst->n_vars; ++i)
+    {
+      struct rank_entry *mre, *next;
+      HMAP_FOR_EACH_SAFE (mre, next, struct rank_entry, node, &kw[i].map)
+       {
+         hmap_delete (&kw[i].map, &mre->node);
+         free (mre);
+       }
+      hmap_destroy (&kw[i].map);
+    }
+
   free (kw);
 }