ROC: Improve error messages and coding style.
[pspp] / src / output / charts / barchart.c
index eb252d4811d2b434991fe087d41d21f8933d3c06..1b946fddffb780a0cd636eb8b3ff15742f4153f3 100644 (file)
@@ -24,7 +24,7 @@
 #include "libpspp/cast.h"
 #include "libpspp/str.h"
 #include "libpspp/array.h"
-#include "output/chart-item-provider.h"
+#include "output/chart-provider.h"
 
 #include "gl/xalloc.h"
 #include "data/variable.h"
@@ -170,12 +170,11 @@ barchart_dump (const struct barchart *bc, FILE *fp)
    CATS are the counts of the values of those variables. N_CATS is the
    number of distinct values.
 */
-struct chart_item *
+struct chart *
 barchart_create (const struct variable **var, int n_vars,
                 const char *ylabel, bool percent,
                 struct freq *const *cats, int n_cats)
 {
-  struct barchart *bar;
   int i;
 
   const int pidx = 0;
@@ -186,12 +185,12 @@ barchart_create (const struct variable **var, int n_vars,
 
   assert (n_vars >= 1 && n_vars <= 2);
 
-  bar = xzalloc (sizeof *bar);
+  struct barchart *bar = XZALLOC (struct barchart);
   bar->percent = percent;
   bar->var = var;
   bar->n_vars = n_vars;
   bar->n_nzcats = n_cats;
-  chart_item_init (&bar->chart_item, &barchart_class, var_to_string (var[pidx]));
+  chart_init (&bar->chart, &barchart_class, var_to_string (var[pidx]));
 
   bar->largest = -1;
   bar->ylabel = strdup (ylabel);
@@ -222,7 +221,7 @@ barchart_create (const struct variable **var, int n_vars,
 
          if (!flag)
            {
-             struct category *s = xzalloc (sizeof *s);
+             struct category *s = XZALLOC (struct category);
              s->idx = idx++;
              s->width = var_get_width (var[pidx]);
              value_init (&s->val, s->width);
@@ -260,7 +259,7 @@ barchart_create (const struct variable **var, int n_vars,
 
          if (!flag)
            {
-             struct category *s = xzalloc (sizeof *s);
+             struct category *s = XZALLOC (struct category);
              s->idx = idx++;
              s->width = var_get_width (var[sidx]);
              value_init (&s->val, s->width);
@@ -341,7 +340,7 @@ barchart_create (const struct variable **var, int n_vars,
   if (settings_get_testing_mode ())
     barchart_dump (bar, stdout);
 
-  return &bar->chart_item;
+  return &bar->chart;
 }
 
 static void
@@ -361,9 +360,9 @@ destroy_cat_map (struct hmap *m)
 }
 
 static void
-barchart_destroy (struct chart_item *chart_item)
+barchart_destroy (struct chart *chart)
 {
-  struct barchart *bar = to_barchart (chart_item);
+  struct barchart *bar = to_barchart (chart);
 
   int i;
 
@@ -384,7 +383,7 @@ barchart_destroy (struct chart_item *chart_item)
   free (bar);
 }
 
-const struct chart_item_class barchart_class =
+const struct chart_class barchart_class =
   {
     barchart_destroy
   };