From: Jason Stover Date: Fri, 14 Sep 2007 01:39:35 +0000 (+0000) Subject: Declare models in difinition of cmd_regression; free moment structure X-Git-Tag: v0.6.0~273 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7ee429e606ed6e711cf8ddd10143e6e9e6bd0dd0;p=pspp-builds.git Declare models in difinition of cmd_regression; free moment structure --- diff --git a/src/language/stats/ChangeLog b/src/language/stats/ChangeLog index 2499a1a6..a36249a9 100644 --- a/src/language/stats/ChangeLog +++ b/src/language/stats/ChangeLog @@ -1,3 +1,10 @@ +2007-09-13 Jason Stover + + * regression.q (cmd_regression): Move declaration of models in to + definition of cmd_regression. + + * regression.q (run_regression): Free mom to fix memory leak. + 2007-09-12 Ben Pfaff * crosstabs.q (postcalc): Free sorted_tab and the structures that diff --git a/src/language/stats/regression.q b/src/language/stats/regression.q index 609ec395..c10cc59e 100644 --- a/src/language/stats/regression.q +++ b/src/language/stats/regression.q @@ -92,9 +92,6 @@ struct moments_var const struct variable *v; }; -/* Linear regression models. */ -static pspp_linreg_cache **models = NULL; - /* Transformations for saving predicted values and residuals, etc. @@ -122,7 +119,7 @@ static size_t n_variables; static struct file_handle *model_file; static bool run_regression (struct casereader *, struct cmd_regression *, - struct dataset *); + struct dataset *, pspp_linreg_cache **); /* STATISTICS subcommand output functions. @@ -948,6 +945,7 @@ cmd_regression (struct lexer *lexer, struct dataset *ds) { struct casegrouper *grouper; struct casereader *group; + pspp_linreg_cache **models; bool ok; size_t i; @@ -963,7 +961,7 @@ cmd_regression (struct lexer *lexer, struct dataset *ds) /* Data pass. */ grouper = casegrouper_create_splits (proc_open (ds), dataset_dict (ds)); while (casegrouper_get_next_group (grouper, &group)) - run_regression (group, &cmd, ds); + run_regression (group, &cmd, ds, models); ok = casegrouper_destroy (grouper); ok = proc_commit (ds) && ok; @@ -1122,7 +1120,7 @@ compute_moments (pspp_linreg_cache * c, struct moments_var *mom, static bool run_regression (struct casereader *input, struct cmd_regression *cmd, - struct dataset *ds) + struct dataset *ds, pspp_linreg_cache **models) { size_t i; int n_indep = 0; @@ -1255,6 +1253,11 @@ run_regression (struct casereader *input, struct cmd_regression *cmd, } casereader_destroy (reader); } + for (i = 0; i < n_variables; i++) + { + moments1_destroy ((mom + i)->m); + } + free (mom); free (indep_vars); free (lopts.get_indep_mean_std); casereader_destroy (input);