Categoricals.c: Ensure that categories are processed order of their categorical varia...
[pspp] / src / math / linreg.c
index 7c85634a50fd28e558cdb8cfef0d38d30da79838..47d21cf8f5fdfed7f357f96f45038493374b6aab 100644 (file)
@@ -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