ctables: Minor refactoring.
[pspp] / src / output / pivot-output.c
index bea33985ebf1d7f0d0c22e94b7b7f243ef77927e..c3751d04d888dff563b28a1155c18143c64f8b80 100644 (file)
 #include "data/settings.h"
 #include "libpspp/assertion.h"
 #include "libpspp/pool.h"
+#include "output/output-item.h"
 #include "output/pivot-table.h"
-#include "output/table-item.h"
 #include "output/table-provider.h"
 #include "output/table.h"
-#include "output/text-item.h"
 
 #include "gl/minmax.h"
 #include "gl/xalloc.h"
@@ -234,7 +233,7 @@ compose_headings (struct table *t,
      |aaaa1|aaaa2|aaaa3|aaaa1|aaaa2|aaaa3|aaaa1|aaaa2|aaaa3|
      +-----+-----+-----+-----+-----+-----+-----+-----+-----+
   */
-  bool *vrules = xzalloc (n_columns + 1);
+  bool *vrules = XCALLOC (n_columns + 1, bool);
   vrules[0] = vrules[n_columns] = true;
   for (int dim_index = h_axis->n_dimensions; --dim_index >= 0; )
     {
@@ -395,9 +394,10 @@ add_references (const struct pivot_table *pt, const struct table *table,
 
         if (x == cell.d[H][0] && y == cell.d[V][0])
           {
-            for (size_t i = 0; i < cell.value->n_footnotes; i++)
+            const struct pivot_value_ex *ex = pivot_value_ex (cell.value);
+            for (size_t i = 0; i < ex->n_footnotes; i++)
               {
-                size_t idx = cell.value->footnote_indexes[i];
+                size_t idx = ex->footnote_indexes[i];
                 assert (idx < pt->n_footnotes);
 
                 if (!refs[idx] && pt->footnotes[idx]->show)
@@ -426,7 +426,7 @@ collect_footnotes (const struct pivot_table *pt,
       return NULL;
     }
 
-  bool *refs = xzalloc (pt->n_footnotes);
+  bool *refs = XCALLOC (pt->n_footnotes, bool);
   size_t n_refs = 0;
   add_references (pt, title, refs, &n_refs);
   add_references (pt, layers, refs, &n_refs);
@@ -662,5 +662,5 @@ pivot_output (const struct pivot_table *pt,
 void
 pivot_table_submit (struct pivot_table *pt)
 {
-  table_item_submit (table_item_create (pt));
+  output_item_submit (table_item_create (pt));
 }