return proto;
}
+
+struct caseproto *
+caseproto_clone (const struct caseproto *in)
+{
+ struct caseproto *proto = xmalloc (caseproto_size (in->n_widths));
+ proto->ref_cnt = 1;
+
+ proto->n_widths = in->n_widths;
+ proto->allocated_widths = in->allocated_widths;
+
+ memcpy (proto->widths, in->widths, proto->n_widths * sizeof *proto->widths);
+
+ proto->n_long_strings = in->n_long_strings;
+ proto->long_strings = NULL;
+ if ( proto->n_long_strings > 0)
+ caseproto_refresh_long_string_cache__ (proto);
+
+ return proto;
+}
+
static void
do_unref (void *proto_)
{
/* Creation and destruction. */
struct caseproto *caseproto_create (void) MALLOC_LIKE;
+struct caseproto *caseproto_clone (const struct caseproto *) ;
static inline struct caseproto *caseproto_ref (const struct caseproto *);
struct caseproto *caseproto_ref_pool (const struct caseproto *, struct pool *);
static inline void caseproto_unref (struct caseproto *);
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;
}
{
struct casereader *u ;
struct casereader *ud ;
- const struct caseproto *output_proto = casereader_get_proto (input);
+ struct caseproto *output_proto = caseproto_clone (casereader_get_proto (input));
struct consolidator *cdr = xmalloc (sizeof (*cdr));
cdr->n = 0;
consolodate_weight,
uniquify_destroy,
cdr);
+
+ return ud;
}