From 422476409ce44ff78786b84a979bf61afe093412 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 13 Oct 2015 20:58:03 +0200 Subject: [PATCH] eliminate memory leak from locales --- src/util/language.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/util/language.c b/src/util/language.c index 1972b38da..05ddf50c9 100644 --- a/src/util/language.c +++ b/src/util/language.c @@ -315,9 +315,23 @@ void reset_locales(void) { void free_locales(void) { locale_init = 0; while (locales) { - int i; + int i, index = locales->index; locale * next = locales->next; + for (i = UT_PARAMS; i != UT_RACES; ++i) { + struct critbit_tree ** cb = (struct critbit_tree **)get_translations(locales, i); + if (*cb) { + // TODO: this crashes? + cb_clear(*cb); + free(*cb); + } + } + for (i = UT_RACES; i != UT_MAX; ++i) { + void *tokens = lstrs[index].tokens[i]; + if (tokens) { + freetokens(tokens); + } + } for (i = 0; i != SMAXHASH; ++i) { while (locales->strings[i]) { struct locale_str * strings = locales->strings[i];