From 4bd4ff4a47e70820ea55a37e27fe731e97cbbd14 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Mon, 20 Jul 2009 06:34:38 +0200 Subject: [PATCH] Replace caseproto_clone with caseproto_ref Also unref the proto on destruction of the translator. --- src/data/caseproto.c | 20 -------------------- src/data/caseproto.h | 1 - src/data/casereader-translator.c | 3 ++- 3 files changed, 2 insertions(+), 22 deletions(-) diff --git a/src/data/caseproto.c b/src/data/caseproto.c index 68df141b..1a40213a 100644 --- a/src/data/caseproto.c +++ b/src/data/caseproto.c @@ -59,26 +59,6 @@ caseproto_create (void) 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_) { diff --git a/src/data/caseproto.h b/src/data/caseproto.h index 3fc8c2c0..b85a9f32 100644 --- a/src/data/caseproto.h +++ b/src/data/caseproto.h @@ -78,7 +78,6 @@ struct pool; /* 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 *); diff --git a/src/data/casereader-translator.c b/src/data/casereader-translator.c index c193d404..feffa15c 100644 --- a/src/data/casereader-translator.c +++ b/src/data/casereader-translator.c @@ -438,6 +438,7 @@ uniquify_destroy (void *aux) struct consolidator *cdr = aux; casereader_destroy (cdr->clone); + caseproto_unref (cdr->proto); free (cdr); return true; @@ -461,7 +462,7 @@ casereader_create_distinct (struct casereader *input, { struct casereader *u ; struct casereader *ud ; - struct caseproto *output_proto = caseproto_clone (casereader_get_proto (input)); + struct caseproto *output_proto = caseproto_ref (casereader_get_proto (input)); struct consolidator *cdr = xmalloc (sizeof (*cdr)); cdr->n = 0; -- 2.30.2