+2007-09-12 Ben Pfaff <blp@gnu.org>
+
+ Make it clear that translator casereader and casewriter translate
+ functions are supposed to destroy their input case.
+
+ * casereader-translator.c (struct casereader_translator): Change
+ input case parameter of translate member function from const
+ struct ccase * to struct ccase *.
+ (casereader_create_translator): Ditto, for translate parameter.
+
+ * casewriter-translator.c (struct casewriter_translator): Ditto.
+ (casewriter_create_translator): Ditto.
+
2007-08-27 John Darrinton <john@darrington.wattle.id.au>
* sys-file-reader.c (read_display_parameters): Force display width
dict_make_compactor.
(scratch_writer_casewriter_write): Use case_map_execute instead of
dict_compactor_compact.
-o
+
2007-08-12 Ben Pfaff <blp@gnu.org>
* automake.mk: Add case-map.c, case-map.h.
{
struct casereader *subreader; /* Source of input cases. */
- void (*translate) (const struct ccase *input, struct ccase *output,
- void *aux);
+ void (*translate) (struct ccase *input, struct ccase *output, void *aux);
bool (*destroy) (void *aux);
void *aux;
};
struct casereader *
casereader_create_translator (struct casereader *subreader,
size_t output_value_cnt,
- void (*translate) (const struct ccase *input,
+ void (*translate) (struct ccase *input,
struct ccase *output,
void *aux),
bool (*destroy) (void *aux),
struct casereader *
casereader_create_translator (struct casereader *, size_t output_value_cnt,
- void (*translate) (const struct ccase *input,
+ void (*translate) (struct ccase *input,
struct ccase *output,
void *aux),
bool (*destroy) (void *aux),
{
struct casewriter *subwriter;
- void (*translate) (const struct ccase *input, struct ccase *output,
- void *aux);
+ void (*translate) (struct ccase *input, struct ccase *output, void *aux);
bool (*destroy) (void *aux);
void *aux;
};
static struct casewriter_class casewriter_translator_class;
+/* Creates and returns a new casewriter whose cases are passed
+ through TRANSLATE, which must create case OUTPUT, with
+ OUTPUT_VALUE_CNT values, and populate it based on INPUT and
+ auxiliary data AUX. The translated cases are then written to
+ SUBWRITER. TRANSLATE must also destroy INPUT.
+
+ When the translating casewriter is destroyed, DESTROY will be
+ called to allow any state maintained by TRANSLATE to be freed.
+
+ After this function is called, SUBWRITER must not ever again
+ be referenced directly. It will be destroyed automatically
+ when the translating casewriter is destroyed. */
struct casewriter *
casewriter_create_translator (struct casewriter *subwriter,
size_t translated_value_cnt,
- void (*translate) (const struct ccase *input,
+ void (*translate) (struct ccase *input,
struct ccase *output,
void *aux),
bool (*destroy) (void *aux),
\f
struct casewriter *
casewriter_create_translator (struct casewriter *, size_t translated_value_cnt,
- void (*translate) (const struct ccase *input,
+ void (*translate) (struct ccase *input,
struct ccase *output,
void *aux),
bool (*destroy) (void *aux),
+2007-09-12 Ben Pfaff <blp@gnu.org>
+
+ * get.c (get_translate_case): Change input case parameter from
+ const struct ccase * to struct ccase *, to match change in
+ casereader and casewriter translators. Destroy input case, to fix
+ memory leak.
+
2007-08-12 Ben Pfaff <blp@gnu.org>
* get.c (parse_read_command): Compact the values in the target
IMPORT_CMD
};
-static void get_translate_case (const struct ccase *, struct ccase *,
- void *map_);
+static void get_translate_case (struct ccase *, struct ccase *, void *map_);
static bool get_destroy_case_map (void *map_);
/* Parses a GET or IMPORT command. */
}
static void
-get_translate_case (const struct ccase *input, struct ccase *output,
+get_translate_case (struct ccase *input, struct ccase *output,
void *map_)
{
struct case_map *map = map_;
case_map_execute (map, input, output);
+ case_destroy (input);
}
static bool