pivot_value_new_user_text_nocopy (text));
}
+ free (datasets);
+
pivot_table_submit (table);
return CMD_SUCCESS;
display_value_labels (vars, n_vars);
display_attributes (dict_get_attributes (dataset_dict (ds)),
vars, n_vars, DF_ATTRIBUTES);
+ free (vars);
dict_unref (d);
for (xt = &proc.pivots[0]; xt < &proc.pivots[proc.n_pivots]; xt++)
{
free (xt->vars);
- /* We must not call value_destroy on const_values because
- it is a wild pointer; it never pointed to anything owned
- by the crosstabulation.
-
- The rest of the data was allocated and destroyed at a
- lower level already. */
+ free (xt->const_vars);
+ free (xt->const_indexes);
}
free (proc.pivots);
xt->vars = xcalloc (n_by, sizeof *xt->vars);
xt->n_consts = 0;
xt->const_vars = NULL;
+ xt->const_indexes = NULL;
for (j = 0; j < n_by; j++)
xt->vars[j].var = by[j][by_iter[j]];
struct crosstabulation subset;
make_crosstabulation_subset (xt, row0, row1, &subset);
output_crosstabulation (proc, &subset);
+ free (subset.const_indexes);
}
}
if (proc->barchart)
ds_cstr (&vars));
ds_destroy (&vars);
- free_var_values (xt, COL_VAR);
+ for (size_t i = 0; i < xt->n_vars; i++)
+ free_var_values (xt, i);
return;
}
free (x.mat);
free (x.row_tot);
free (x.col_tot);
+ free (x.const_indexes);
}
if (table)
/* Given an array of ENTRY_CNT table_entry structures starting at
ENTRIES, creates a sorted list of the values that the variable
- with index VAR_IDX takes on. The values are returned as a
- malloc()'d array stored in *VALUES, with the number of values
- stored in *VALUE_CNT.
-
- The caller must eventually free *VALUES, but each pointer in *VALUES points
- to existing data not owned by *VALUES itself. */
+ with index VAR_IDX takes on. Stores the array of the values in
+ XT->values and the number of values in XT->n_values. */
static void
enum_var_values (const struct crosstabulation *xt, int var_idx,
bool descending)
free_var_values (const struct crosstabulation *xt, int var_idx)
{
struct xtab_var *xv = &xt->vars[var_idx];
- //free (xv->values);
+ free (xv->values);
xv->values = NULL;
xv->n_values = 0;
}
}
}
}
+
+ free (indexes);
}
static void calc_r (struct crosstabulation *,
struct pivot_value *total = pivot_value_new_number (xt->total);
pivot_value_set_rc (sym, total, PIVOT_RC_COUNT);
pivot_table_put (sym, indexes, sym->n_dimensions, total);
+
+ free (indexes);
}
static bool calc_risk (struct crosstabulation *,
pivot_value_new_number (entries[j]));
}
}
+
+ free (indexes);
}
\f
/* Statistical calculations. */
{
do_factor_by_matrix (&factor, id);
+ gsl_matrix_free (id->ai_cov);
+ id->ai_cov = NULL;
+ gsl_matrix_free (id->ai_cor);
+ id->ai_cor = NULL;
gsl_matrix_free (id->mm.corr);
id->mm.corr = NULL;
gsl_matrix_free (id->mm.cov);
}
if ( ll_count (coefficient_list) <= 0)
- goto error;
+ {
+ destroy_coeff_list (cl);
+ goto error;
+ }
ll_push_tail (&oneway.contrast_list, &cl->ll);
}
pivot_table_put2 (table, j, row_idx,
pivot_value_new_user_text (entry, -1));
}
+ ds_destroy (&group_vars);
}
}
}
}
+ string_set_destroy (&rc_names);
return CMD_SUCCESS;
error:
free (cat->iap[i].enc_sum);
hmap_destroy (&cat->iap[i].ivmap);
}
+ free (cat->iap);
/* Interate over each variable and delete its value map.
}
static void
-ascii_output_text (struct ascii_driver *a, const char *text)
+ascii_output_table_item_unref (struct ascii_driver *a,
+ struct table_item *table_item)
{
- struct table_item *table_item;
-
- table_item = table_item_create (table_from_string (TABLE_HALIGN_LEFT, text),
- NULL, NULL);
ascii_output_table_item (a, table_item);
table_item_unref (table_item);
}
+static void
+ascii_output_text (struct ascii_driver *a, const char *text)
+{
+ ascii_output_table_item_unref (
+ a, table_item_create (table_from_string (TABLE_HALIGN_LEFT, text),
+ NULL, NULL));
+}
+
static void
ascii_submit (struct output_driver *driver,
const struct output_item *output_item)
break;
default:
- ascii_output_table_item (a, text_item_to_table_item (text_item_ref (text_item)));
+ ascii_output_table_item_unref (
+ a, text_item_to_table_item (text_item_ref (text_item)));
break;
}
}
struct box_whisker *bw, const char *label)
{
if (boxplot == NULL)
- return;
+ {
+ struct statistic *statistic = &bw->parent.parent;
+ statistic->destroy (statistic);
+ return;
+ }
struct boxplot_box *box;
if (boxplot->n_boxes >= boxplot->boxes_allocated)
struct output_driver driver;
struct zip_writer *zip; /* ZIP file writer. */
+ struct file_handle *handle; /* Handle for 'file_name'. */
char *file_name; /* Output file name. */
/* content.xml */
output_driver_init (d, &odt_driver_class, file_name, device_type);
odt->zip = zip;
+ odt->handle = fh;
odt->file_name = xstrdup (file_name);
if (!create_mimetype (zip))
zip_writer_close (odt->zip);
}
+ fh_unref (odt->handle);
free (odt->file_name);
free (odt);
}
struct footnote **footnotes = xcalloc (st->n_footnotes, sizeof *footnotes);
for (size_t i = 0; i < st->n_footnotes; i++)
- footnotes[i] = tab_create_footnote (
- table, i,
- pivot_value_to_string (st->footnotes[i]->content,
- st->show_values, st->show_variables),
- pivot_value_to_string (st->footnotes[i]->marker,
- st->show_values, st->show_variables),
- area_style_override (table->container, &st->areas[PIVOT_AREA_FOOTER],
- st->footnotes[i]->content->cell_style,
- st->footnotes[i]->content->font_style));
+ {
+ char *content = pivot_value_to_string (
+ st->footnotes[i]->content, st->show_values, st->show_variables);
+ char *marker = pivot_value_to_string (
+ st->footnotes[i]->marker, st->show_values, st->show_variables);
+ footnotes[i] = tab_create_footnote (
+ table, i, content, marker,
+ area_style_override (table->container, &st->areas[PIVOT_AREA_FOOTER],
+ st->footnotes[i]->content->cell_style,
+ st->footnotes[i]->content->font_style));
+ free (marker);
+ free (content);
+ }
compose_headings (table,
&st->axes[PIVOT_AXIS_COLUMN], H, &st->axes[PIVOT_AXIS_ROW],
table_item_text_destroy (caption);
}
+ free (footnotes);
table_item_submit (ti);
}
void
-pivot_table_submit (const struct pivot_table *st)
+pivot_table_submit (struct pivot_table *st)
{
pivot_table_assign_label_depth (CONST_CAST (struct pivot_table *, st));
pivot_table_submit_layer (st, st->current_layer);
settings_set_decimal_char (old_decimal);
+
+ pivot_table_destroy (st);
}
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
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
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;
bool pivot_table_is_empty (const struct pivot_table *);
/* Output. */
-void pivot_table_submit (const struct pivot_table *);
+void pivot_table_submit (struct pivot_table *);
/* Data cells. */
void pivot_table_put (struct pivot_table *, const size_t *dindexes, size_t n,
struct line_reader *r;
const char *filename;
struct string line;
- char *encoding;
if (argc != 4)
error (1, 0, "bad syntax for `%s' command; use `%s help' for help",
if (r == NULL)
error (1, errno, "line_reader_open failed");
- encoding = xstrdup (line_reader_get_encoding (r));
+ char *encoding = xstrdup (line_reader_get_encoding (r));
printf ("encoded in %s", encoding);
if (line_reader_is_auto (r))
printf (" (auto)");
ds_clear (&line);
}
+ free (encoding);
if (!strcmp(filename, "-"))
line_reader_free (r);
#include <stdio.h>
#include <string.h>
+#include "data/file-handle-def.h"
#include "libpspp/assertion.h"
#include "libpspp/compiler.h"
#include "libpspp/string-map.h"
fclose (input);
output_engine_pop ();
+ fh_done ();
return 0;
}