From: John Darrington Date: Mon, 13 Aug 2012 19:13:56 +0000 (+0200) Subject: Fix leaks in MEANS command X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;ds=inline;h=7dfbf1beae10727cc07213b2c74a991859f9fcbc;p=pspp Fix leaks in MEANS command --- diff --git a/src/language/stats/means.c b/src/language/stats/means.c index c67d75002f..888a6a7583 100644 --- a/src/language/stats/means.c +++ b/src/language/stats/means.c @@ -1,4 +1,3 @@ - /* PSPP - a program for statistical analysis. Copyright (C) 2011, 2012 Free Software Foundation, Inc. @@ -828,6 +827,22 @@ struct per_cat_data bool warn; }; + +static void +destroy_n (const void *aux1 UNUSED, void *aux2, void *user_data) +{ + struct mtable *table = aux2; + int v; + struct per_cat_data *per_cat_data = user_data; + struct per_var_data *pvd = per_cat_data->pvd; + + for (v = 0; v < table->n_dep_vars; ++v) + { + struct per_var_data *pp = &pvd[v]; + moments1_destroy (pp->mom); + } +} + static void * create_n (const void *aux1, void *aux2) { @@ -940,7 +955,7 @@ run_means (struct means *cmd, struct casereader *input, payload.create = create_n; payload.update = update_n; payload.calculate = calculate_n; - payload.destroy = NULL; + payload.destroy = destroy_n; for (t = 0; t < cmd->n_tables; ++t) { diff --git a/src/language/stats/oneway.c b/src/language/stats/oneway.c index 13c1625be1..735c6d441c 100644 --- a/src/language/stats/oneway.c +++ b/src/language/stats/oneway.c @@ -637,7 +637,7 @@ makeit (const void *aux1, void *aux2 UNUSED) } static void -killit (const void *aux1 UNUSED, void *user_data) +killit (const void *aux1 UNUSED, void *aux2 UNUSED, void *user_data) { struct descriptive_data *dd = user_data; diff --git a/src/math/categoricals.c b/src/math/categoricals.c index 43edd048dc..b9748c759e 100644 --- a/src/math/categoricals.c +++ b/src/math/categoricals.c @@ -254,7 +254,7 @@ categoricals_destroy (struct categoricals *cat) HMAP_FOR_EACH (iv, struct interaction_value, node, &cat->iap[i].ivmap) { if (cat->payload && cat->payload->destroy) - cat->payload->destroy (cat->aux1, iv->user_data); + cat->payload->destroy (cat->aux1, cat->aux2, iv->user_data); case_unref (iv->ccase); } diff --git a/src/math/categoricals.h b/src/math/categoricals.h index 3fa6c36d90..53e309ed62 100644 --- a/src/math/categoricals.h +++ b/src/math/categoricals.h @@ -107,7 +107,7 @@ struct payload void* (*create) (const void *aux1, void *aux2); void (*update) (const void *aux1, void *aux2, void *user_data, const struct ccase *, double weight); void (*calculate) (const void *aux1, void *aux2, void *user_data); - void (*destroy) (const void *aux1, void *user_data); + void (*destroy) (const void *aux1, void *aux2, void *user_data); };