summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKalev Lember <klember@redhat.com>2017-01-28 17:45:18 +0100
committerKalev Lember <klember@redhat.com>2017-01-28 17:52:02 +0100
commit5a9a12c1755424ea24fd304c91631489cc6c5e24 (patch)
tree4364097fcfc4d131669b0e00bbdeaf8adb7220d9
parenta3c03baee4b9ea9cb6ad8c4f04ab54c7fdec0a05 (diff)
downloadappstream-glib-wip/kalev/as-ref-string-destructor.tar.gz
Add a destructor for AsRefStringwip/kalev/as-ref-string-destructor
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.
-rw-r--r--libappstream-glib/as-ref-string.c6
1 files changed, 6 insertions, 0 deletions
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