while (d->var_cnt > 0 )
{
- struct variable *v = d->var[d->var_cnt - 1];
- int dict_index = var_get_dict_index (v);
- int case_index = var_get_case_index (v);
- int val_cnt = var_get_value_cnt (v);
-
- var_clear_vardict (v);
- var_destroy (v);
-
- d->var_cnt--;
-
- if (d->callbacks && d->callbacks->var_deleted )
- d->callbacks->var_deleted (d,
- dict_index, case_index, val_cnt,
- d->cb_data);
+ dict_delete_var (d, d->var[d->var_cnt - 1]);
}
free (d->var);
var_clear_vardict (v);
var_destroy (v);
+
if (d->callbacks && d->callbacks->var_deleted )
d->callbacks->var_deleted (d, dict_index, case_index, val_cnt, d->cb_data);
}
assert (cnt == 0 || split != NULL);
d->split_cnt = cnt;
- d->split = cnt > 0 ? xnrealloc (d->split, cnt, sizeof *d->split) : NULL;
- memcpy (d->split, split, cnt * sizeof *d->split);
+ if ( cnt > 0 )
+ {
+ d->split = xnrealloc (d->split, cnt, sizeof *d->split) ;
+ memcpy (d->split, split, cnt * sizeof *d->split);
+ }
+ else
+ {
+ free (d->split);
+ d->split = NULL;
+ }
if ( d->callbacks && d->callbacks->split_changed )
d->callbacks->split_changed (d, d->cb_data);
{
assert (!var_has_vardict (v));
cat_stored_values_destroy (v->obs_vals);
+ var_clear_short_names (v);
var_clear_aux (v);
val_labs_destroy (v->val_labs);
var_clear_label (v);
{
size_t old_cnt = var->short_name_cnt;
size_t i;
-
var->short_name_cnt = MAX (idx * 2, 1);
var->short_names = xnrealloc (var->short_names, var->short_name_cnt,
sizeof *var->short_names);
var_clear_short_names (struct variable *v)
{
size_t i;
-
+
for (i = 0; i < v->short_name_cnt; i++)
free (v->short_names[i]);
+ free (v->short_names);
v->short_names = NULL;
v->short_name_cnt = 0;
}