Replace numerous instances of xzalloc with XZALLOC
[pspp] / src / language / stats / means.c
index 94ee1d1956409c276587865c79c9e0ebb522081a..0a3b413df721e7c8ef1f6114a358d1dcc523c885 100644 (file)
@@ -198,6 +198,8 @@ means_destroy_cells (const struct means *means, struct cell *cell,
   destroy_cell (means, table, cell);
 }
 
+#if 0
+
 static void
 dump_cell (const struct cell *cell, const struct mtable *mt, int level)
 {
@@ -258,6 +260,8 @@ dump_tree (const struct cell *cell, const struct mtable *table,
     }
 }
 
+#endif
+
 /* Generate a hash based on the values of the N variables in
    the array VARS which are taken from the case C.  */
 static unsigned int
@@ -296,7 +300,7 @@ generate_cell (const struct means *means,
               const struct workspace *ws)
 {
   int n_vars = count_one_bits (not_wild);
-  struct cell *cell = xzalloc ((sizeof *cell));
+  struct cell *cell = XZALLOC (struct cell);
   cell->values = xcalloc (n_vars, sizeof *cell->values);
   cell->vars = xcalloc (n_vars, sizeof *cell->vars);
   cell->not_wild = not_wild;
@@ -533,7 +537,7 @@ populate_table (const struct means *means, const struct mtable *mt,
                 const struct cell *cell,
                 struct pivot_table *pt)
 {
-  size_t *indexes = xcalloc (pt->n_dimensions, sizeof *indexes);
+  size_t *indexes = XCALLOC (pt->n_dimensions, size_t);
   for (int v = 0; v < mt->n_dep_vars; ++v)
     {
       for (int s = 0; s < means->n_statistics; ++s)
@@ -747,7 +751,6 @@ means_shipout_single (const struct mtable *mt, const struct means *means,
                      const struct workspace *ws)
 {
   struct pivot_table *pt = pivot_table_create (N_("Report"));
-  pt->omit_empty = true;
 
   struct pivot_dimension *dim_cells =
     pivot_dimension_create (pt, PIVOT_AXIS_COLUMN, N_("Statistics"));
@@ -775,22 +778,20 @@ means_shipout_multivar (const struct mtable *mt, const struct means *means,
   ds_init_empty (&dss);
   for (int dv = 0; dv < mt->n_dep_vars; ++dv)
     {
-      ds_put_cstr (&dss, var_get_name (mt->dep_vars[dv]));
-      if (mt->n_layers > 0)
+      if (dv > 0)
        ds_put_cstr (&dss, " * ");
+      ds_put_cstr (&dss, var_get_name (mt->dep_vars[dv]));
     }
 
   for (int l = 0; l < mt->n_layers; ++l)
     {
+      ds_put_cstr (&dss, " * ");
       const struct layer *layer = mt->layers[l];
       const struct variable *var = layer->factor_vars[ws->control_idx[l]];
       ds_put_cstr (&dss, var_get_name (var));
-      if (l < mt->n_layers - 1)
-       ds_put_cstr (&dss, " * ");
     }
 
   struct pivot_table *pt = pivot_table_create (ds_cstr (&dss));
-  pt->omit_empty = true;
   ds_destroy (&dss);
 
   struct pivot_dimension *dim_cells =
@@ -938,7 +939,7 @@ service_cell_map (const struct means *means, const struct mtable *mt,
                                                               NULL);
                   stat_update *su = cell_spec[means->statistics[stat]].su;
                   su (cell->stat[stat + v * means->n_statistics], weight,
-                     case_data (c, dep_var)->f);
+                     case_num (c, dep_var));
                 }
             }
         }