Replace numerous instances of xzalloc with XZALLOC
[pspp] / src / output / charts / scatterplot.c
index 2c3ffd683f23c7aa1e8d70ca7c7d9e73b8194b8c..5e8d27155e72606d850d979dfec12bb91c73c1a7 100644 (file)
 #include <gsl/gsl_cdf.h>
 
 #include "data/casereader.h"
+#include "data/variable.h"
 #include "libpspp/cast.h"
-#include "output/chart-item-provider.h"
+#include "output/chart-provider.h"
 
 #include "gl/minmax.h"
 
 /* Creates a scatterplot */
 struct scatterplot_chart *
-scatterplot_create (const struct casereader *reader, 
+scatterplot_create (struct casereader *reader,
                    const char *xlabel,
                    const char *ylabel,
                    const struct variable *byvar,
@@ -36,10 +37,8 @@ scatterplot_create (const struct casereader *reader,
                    const char *label,
                    double xmin, double xmax, double ymin, double ymax)
 {
-  struct scatterplot_chart *spc;
-
-  spc = xzalloc (sizeof *spc);
-  chart_item_init (&spc->chart_item, &scatterplot_chart_class, label);
+  struct scatterplot_chart *spc = XZALLOC (struct scatterplot_chart);
+  chart_init (&spc->chart, &scatterplot_chart_class, label);
   spc->data = reader;
 
   spc->y_min = ymin;
@@ -58,18 +57,18 @@ scatterplot_create (const struct casereader *reader,
 }
 
 static void
-scatterplot_chart_destroy (struct chart_item *chart_item)
+scatterplot_chart_destroy (struct chart *chart)
 {
-  struct scatterplot_chart *spc = to_scatterplot_chart (chart_item);
+  struct scatterplot_chart *spc = to_scatterplot_chart (chart);
   casereader_destroy (spc->data);
   free (spc->xlabel);
   free (spc->ylabel);
   if (spc->byvar)
-    var_destroy (spc->byvar);
+    var_unref (spc->byvar);
   free (spc);
 }
 
-const struct chart_item_class scatterplot_chart_class =
+const struct chart_class scatterplot_chart_class =
   {
     scatterplot_chart_destroy
   };