Reorganised the text-data import assistant into separate files for each page
[pspp] / src / math / linreg.c
index 90c62a5258640fdfb9a1eeb8b29bd4164ba77d29..47d21cf8f5fdfed7f357f96f45038493374b6aab 100644 (file)
@@ -107,23 +107,29 @@ 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);
+      gsl_vector_free (c->ss_indeps);
       gsl_matrix_free (c->cov);
       free (c->indep_vars);
       free (c->coeff);
       free (c);
     }
-  return true;
 }
 
 static void