From 5a9a12c1755424ea24fd304c91631489cc6c5e24 Mon Sep 17 00:00:00 2001 From: Kalev Lember Date: Sat, 28 Jan 2017 17:45:18 +0100 Subject: Add a destructor for AsRefString AsRefString uses a singleton hash table for deduplicating strings. This is all "possibly lost" memory according to valgrind as the hash table never gets destroyed. This commit adds a custom destructor so that we can clean up the singleton hash table as well and avoid unnecessary noise in valgrind output. --- libappstream-glib/as-ref-string.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libappstream-glib/as-ref-string.c b/libappstream-glib/as-ref-string.c index 054d243..702de91 100644 --- a/libappstream-glib/as-ref-string.c +++ b/libappstream-glib/as-ref-string.c @@ -64,6 +64,12 @@ as_ref_string_get_hash_safe (void) return as_ref_string_hash; } +static void __attribute__ ((destructor)) +as_ref_string_destructor (void) +{ + g_clear_pointer (&as_ref_string_hash, g_hash_table_unref); +} + /** * as_ref_string_new_static: * @str: a string -- cgit v1.2.1