From 5cbc67f89fb35bb15a59870be6f92984a87fb70f Mon Sep 17 00:00:00 2001 From: Jason H Stover Date: Fri, 29 Jan 2010 23:15:07 -0500 Subject: [PATCH] allocate space to store independent variable list --- src/math/linreg.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/math/linreg.c b/src/math/linreg.c index bb4de0c2..c5ecf5ac 100644 --- a/src/math/linreg.c +++ b/src/math/linreg.c @@ -70,10 +70,15 @@ linreg_alloc (const struct variable *depvar, const struct variable **indep_vars, double n, size_t p) { linreg *c; + size_t i; c = xmalloc (sizeof (linreg)); c->depvar = depvar; - c->indep_vars = indep_vars; + c->indep_vars = xnmalloc (p, sizeof (*indep_vars)); + for (i = 0; i < p; i++) + { + c->indep_vars[i] = indep_vars[i]; + } c->indep_means = gsl_vector_alloc (p); c->indep_std = gsl_vector_alloc (p); c->ssx = gsl_vector_alloc (p); /* Sums of squares for the @@ -111,6 +116,7 @@ linreg_free (void *m) gsl_vector_free (c->indep_std); gsl_matrix_free (c->cov); gsl_vector_free (c->ssx); + free (c->indep_vars); free (c->coeff); free (c); } -- 2.30.2