table->layers = NULL;
/* Dependent variable (s) */
- if (!parse_variables_const (lexer, cmd->dict,
+ if (!parse_variables_const_pool (lexer, cmd->pool, cmd->dict,
&table->dep_vars, &table->n_dep_vars,
PV_NO_DUPLICATE | PV_NUMERIC))
return false;
{
table->n_layers++;
table->layers =
- xrealloc (table->layers,
+ pool_realloc (cmd->pool, table->layers,
sizeof (*table->layers) * table->n_layers);
- if (!parse_variables_const
- (lexer, cmd->dict,
+ if (!parse_variables_const_pool
+ (lexer, cmd->pool, cmd->dict,
&table->layers[table->n_layers - 1].factor_vars,
&table->layers[table->n_layers - 1].n_factor_vars,
PV_NO_DUPLICATE))
table->n_layers++;
table->layers =
- xrealloc (table->layers,
+ pool_realloc (cmd->pool, table->layers,
sizeof (*table->layers) * table->n_layers);
table->layers[table->n_layers - 1].factor_vars = NULL;
table->layers[table->n_layers - 1].n_factor_vars = 0;
struct means means;
bool more_tables = true;
+ means.pool = pool_create ();
+
means.exclude = MV_ANY;
means.dep_exclude = MV_ANY;
means.listwise_exclude = false;
means.dict = dataset_dict (ds);
means.n_cells = 3;
- means.cells = xcalloc (means.n_cells, sizeof (*means.cells));
+ means.cells = pool_calloc (means.pool, means.n_cells, sizeof (*means.cells));
/* The first three items (MEAN, COUNT, STDDEV) are the default */
while (more_tables)
{
means.n_tables ++;
- means.table = xrealloc (means.table, means.n_tables * sizeof (*means.table));
+ means.table = pool_realloc (means.pool, means.table, means.n_tables * sizeof (*means.table));
if (! parse_means_table_syntax (lexer, &means,
&means.table[means.n_tables - 1]))
{
int x;
means.cells =
- xrealloc (means.cells,
+ pool_realloc (means.pool, means.cells,
(means.n_cells += n_C) * sizeof (*means.cells));
for (x = 0; x < n_C; ++x)
else if (lex_match_id (lexer, "DEFAULT"))
{
means.cells =
- xrealloc (means.cells,
+ pool_realloc (means.pool, means.cells,
(means.n_cells += 3) * sizeof (*means.cells));
means.cells[means.n_cells - 2 - 1] = MEANS_MEAN;
if (lex_match_id (lexer, cell_spec[k].keyword))
{
means.cells =
- xrealloc (means.cells,
+ pool_realloc (means.pool, means.cells,
++means.n_cells * sizeof (*means.cells));
means.cells[means.n_cells - 1] = k;
}
}
- means.pool = pool_create ();
for (t = 0; t < means.n_tables; ++t)
struct mtable *table = &means.table[t];
table->interactions =
- xcalloc (table->n_layers, sizeof (*table->interactions));
+ pool_calloc (means.pool, table->n_layers, sizeof (*table->interactions));
table->summary =
- xcalloc (table->n_dep_vars * table->n_layers, sizeof (*table->summary));
+ pool_calloc (means.pool, table->n_dep_vars * table->n_layers, sizeof (*table->summary));
for (l = 0; l < table->n_layers; ++l)
{
}
+ pool_destroy (means.pool);
return CMD_SUCCESS;
error:
+ pool_destroy (means.pool);
return CMD_FAILURE;
}
bool warn;
};
+
+static void
+destroy_n (const void *aux1 UNUSED, void *aux2, void *user_data)
+{
+ struct mtable *table = aux2;
+ int v;
+ struct per_cat_data *per_cat_data = user_data;
+ struct per_var_data *pvd = per_cat_data->pvd;
+
+ for (v = 0; v < table->n_dep_vars; ++v)
+ {
+ struct per_var_data *pp = &pvd[v];
+ moments1_destroy (pp->mom);
+ }
+}
+
static void *
create_n (const void *aux1, void *aux2)
{
int i, v;
const struct means *means = aux1;
struct mtable *table = aux2;
- struct per_cat_data *per_cat_data = xmalloc (sizeof *per_cat_data);
+ struct per_cat_data *per_cat_data = pool_malloc (means->pool, sizeof *per_cat_data);
- struct per_var_data *pvd = xcalloc (table->n_dep_vars, sizeof *pvd);
+ struct per_var_data *pvd = pool_calloc (means->pool, table->n_dep_vars, sizeof *pvd);
for (v = 0; v < table->n_dep_vars; ++v)
{
enum moment maxmom = MOMENT_KURTOSIS;
struct per_var_data *pp = &pvd[v];
- pp->cell_stats = xcalloc (means->n_cells, sizeof *pp->cell_stats);
+ pp->cell_stats = pool_calloc (means->pool, means->n_cells, sizeof *pp->cell_stats);
for (i = 0; i < means->n_cells; ++i)
struct payload payload;
payload.create = create_n;
payload.update = update_n;
- payload.destroy = calculate_n;
+ payload.calculate = calculate_n;
+ payload.destroy = destroy_n;
for (t = 0; t < cmd->n_tables; ++t)
{
struct mtable *table = &cmd->table[t];
table->cats
= categoricals_create (table->interactions,
- table->n_layers, wv, cmd->exclude);
+ table->n_layers, wv, cmd->dep_exclude, cmd->exclude);
categoricals_set_payload (table->cats, &payload, cmd, table);
}
- for (reader = casereader_clone (input);
+ for (reader = input;
(c = casereader_read (reader)) != NULL; case_unref (c))
{
for (t = 0; t < cmd->n_tables; ++t)
tab_box (t, TAL_2, TAL_2, -1, TAL_1, 0, 0, nc - 1, nr - 1);
tab_hline (t, TAL_2, 0, nc - 1, heading_rows);
- tab_vline (t, TAL_2, iact->n_vars, 0, nr - 1);
+ tab_vline (t, TAL_2, heading_columns, 0, nr - 1);
for (i = 0; i < iact->n_vars; ++i)
{
tab_text (t, 0,
heading_rows + dv * n_cats,
TAB_RIGHT | TAT_TITLE,
- var_get_name (table->dep_vars[dv])
+ var_to_string (table->dep_vars[dv])
);
if ( dv > 0)