work
[pspp] / src / output / pivot-table.c
index c024f142ee8917637e98ef53013b8222902d1e6e..96821170eff043db82a47e88004d19f2ba84747c 100644 (file)
@@ -293,6 +293,7 @@ pivot_dimension_destroy (struct pivot_dimension *d)
   pivot_category_destroy (d->root);
   free (d->data_leaves);
   free (d->presentation_leaves);
+  free (d);
 }
 
 /* Returns the first leaf node in an in-order traversal that is a child of
@@ -505,6 +506,7 @@ pivot_category_destroy (struct pivot_category *c)
   pivot_value_destroy (c->name);
   for (size_t i = 0; i < c->n_subs; i++)
     pivot_category_destroy (c->subs[i]);
+  free (c->subs);
   free (c);
 }
 \f
@@ -694,9 +696,7 @@ pivot_table_create__ (struct pivot_value *title)
 }
 
 /* Creates and returns a new pivot table with the given TITLE and a single cell
-   with the given CONTENT.
-
-   This is really just for error handling. */
+   with the given CONTENT. */
 struct pivot_table *
 pivot_table_create_for_text (struct pivot_value *title,
                              struct pivot_value *content)
@@ -1200,12 +1200,14 @@ pivot_table_assign_label_depth (struct pivot_table *table)
     table->axes[PIVOT_AXIS_COLUMN].label_depth = 1;
   pivot_axis_assign_label_depth (table, PIVOT_AXIS_LAYER, false);
 }
-\f
-/* Footnotes. */
 
+void
+pivot_table_submit (struct pivot_table *pt)
+{
+  pivot_table_assign_label_depth (CONST_CAST (struct pivot_table *, pt));
+  table_item_submit (table_item_create (pt));
 \f
-\f
-static void
+  static void
 indent (int indentation)
 {
   for (int i = 0; i < indentation * 2; i++)
@@ -1268,7 +1270,7 @@ void
 pivot_dimension_dump (const struct pivot_dimension *d, int indentation)
 {
   indent (indentation);
-  printf ("%s dimension %zu (where 0=innermost), label_depth=%zu:\n",
+  printf ("%s dimension %zu (where 0=innermost), label_depth=%d:\n",
           pivot_axis_type_to_string (d->axis_type), d->level, d->label_depth);
 
   pivot_category_dump (d->root, indentation + 1);
@@ -1520,7 +1522,7 @@ pivot_table_dump (const struct pivot_table *table, int indentation)
       if (f->marker)
         pivot_value_dump (f->marker);
       else
-        printf ("%d", f->idx);
+        printf ("%zu", f->idx);
       putchar (']');
       pivot_value_dump (f->content);
       putchar ('\n');
@@ -1789,8 +1791,8 @@ pivot_value_destroy (struct pivot_value *value)
       font_style_uninit (value->font_style);
       free (value->font_style);
       free (value->cell_style);
-      for (size_t i = 0; i < value->n_footnotes; i++)
-        pivot_footnote_destroy (value->footnotes[i]);
+      /* Do not free the elements of footnotes because VALUE does not own
+         them. */
       free (value->footnotes);
 
       switch (value->type)
@@ -1800,7 +1802,8 @@ pivot_value_destroy (struct pivot_value *value)
           free (value->numeric.value_label);
           break;
 
-        case SETTINGS_VALUE_SHOW_VALUE:
+        case PIVOT_VALUE_STRING:
+          free (value->string.s);
           free (value->string.var_name);
           free (value->string.value_label);
           break;