\f
-struct consolodator
+struct consolidator
{
const struct variable *key;
const struct variable *weight;
static bool
uniquify (const struct ccase *c, void *aux)
{
- struct consolodator *cdr = aux;
+ struct consolidator *cdr = aux;
const union value *current_value = case_data (c, cdr->key);
const int key_width = var_get_width (cdr->key);
const double weight = cdr->weight ? case_data (c, cdr->weight)->f : 1.0;
static struct ccase *
consolodate_weight (struct ccase *input, void *aux)
{
- struct consolodator *cdr = aux;
+ struct consolidator *cdr = aux;
struct ccase *c;
- c = case_unshare_and_resize (input, cdr->proto);
-
if (cdr->weight)
- case_data_rw (c, cdr->weight)->f = cdr->prev_cc;
+ {
+ c = case_unshare (input);
+ case_data_rw (c, cdr->weight)->f = cdr->prev_cc;
+ }
else
- case_data_rw_idx (c, caseproto_get_n_widths (cdr->proto) - 1)->f = cdr->prev_cc;
+ {
+ c = case_unshare_and_resize (input, cdr->proto);
+ case_data_rw_idx (c, caseproto_get_n_widths (cdr->proto) - 1)->f = cdr->prev_cc;
+ }
return c;
}
static bool
uniquify_destroy (void *aux)
{
- struct consolodator *cdr = aux;
+ struct consolidator *cdr = aux;
casereader_destroy (cdr->clone);
+ caseproto_unref (cdr->proto);
free (cdr);
return true;
{
struct casereader *u ;
struct casereader *ud ;
- const struct caseproto *output_proto = casereader_get_proto (input);
+ struct caseproto *output_proto = caseproto_ref (casereader_get_proto (input));
- struct consolodator *cdr = xmalloc (sizeof (*cdr));
+ struct consolidator *cdr = xmalloc (sizeof (*cdr));
cdr->n = 0;
cdr->key = key;
cdr->weight = weight;
consolodate_weight,
uniquify_destroy,
cdr);
+
+ return ud;
}