struct pivot_table *
pivot_table_create__ (struct pivot_value *title, const char *subtype)
{
- struct pivot_table *table = xzalloc (sizeof *table);
+ struct pivot_table *table = XZALLOC (struct pivot_table);
table->ref_cnt = 1;
table->show_title = true;
table->show_caption = true;
.extra_depth = old->extra_depth,
.subs = (old->n_subs
- ? xzalloc (old->n_subs * sizeof *new->subs)
+ ? xcalloc (old->n_subs, sizeof *new->subs)
: NULL),
.n_subs = old->n_subs,
.allocated_subs = old->n_subs,
.axis_type = old->axis_type,
.level = old->level,
.top_index = old->top_index,
- .data_leaves = xzalloc (old->n_leaves * sizeof *new->data_leaves),
- .presentation_leaves = xzalloc (old->n_leaves
- * sizeof *new->presentation_leaves),
+ .data_leaves = xcalloc (old->n_leaves , sizeof *new->data_leaves),
+ .presentation_leaves = xcalloc (old->n_leaves
+ , sizeof *new->presentation_leaves),
.n_leaves = old->n_leaves,
.allocated_leaves = old->n_leaves,
.hide_all_labels = old->hide_all_labels,
pivot_value_new_value (const union value *value, int width,
const struct fmt_spec *format, const char *encoding)
{
- struct pivot_value *pv = xzalloc (sizeof *pv);
+ struct pivot_value *pv = XZALLOC (struct pivot_value);
if (width > 0)
{
char *s = recode_string (UTF8, encoding, CHAR_CAST (char *, value->s),
/* Returns a new pivot_value for VARIABLE. */
struct pivot_value *
pivot_value_new_variable (const struct variable *variable)
+{
+ return pivot_value_new_variable__ (var_get_name (variable),
+ var_get_label (variable));
+}
+
+/* Returns a new pivot_value for a variable with the given NAME and optional
+ LABEL. */
+struct pivot_value *
+pivot_value_new_variable__ (const char *name, const char *label)
{
struct pivot_value *value = xmalloc (sizeof *value);
*value = (struct pivot_value) {
.variable = {
.type = PIVOT_VALUE_VARIABLE,
- .var_name = xstrdup (var_get_name (variable)),
- .var_label = xstrdup_if_nonempty (var_get_label (variable)),
+ .var_name = xstrdup (name),
+ .var_label = xstrdup_if_nonempty (label),
},
};
return value;