X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fmath%2Flinreg.c;h=47d21cf8f5fdfed7f357f96f45038493374b6aab;hb=bb0e1c1f8b1a87a0ccd9bb4ffb22466475a47b7f;hp=7c85634a50fd28e558cdb8cfef0d38d30da79838;hpb=e8566274867b259ca29b7ae8c867194099fc27f4;p=pspp diff --git a/src/math/linreg.c b/src/math/linreg.c index 7c85634a50..47d21cf8f5 100644 --- a/src/math/linreg.c +++ b/src/math/linreg.c @@ -107,14 +107,20 @@ linreg_alloc (const struct variable *depvar, const struct variable **indep_vars, c->pred = NULL; c->resid = NULL; + c->refcnt = 1; return c; } -bool -linreg_free (void *m) +void +linreg_ref (linreg *c) +{ + c->refcnt++; +} + +void +linreg_unref (linreg *c) { - linreg *c = m; - if (c != NULL) + if (c && --c->refcnt == 0) { gsl_vector_free (c->indep_means); gsl_vector_free (c->indep_std); @@ -124,7 +130,6 @@ linreg_free (void *m) free (c->coeff); free (c); } - return true; } static void