From 55e79c377249bc653613e26b3b0e515df5fadbdf Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Sun, 14 Jul 2019 22:41:56 +0300 Subject: [PATCH] info: Free some more memory on gst_deinit() --- gst/gst.c | 6 +++++- gst/gstinfo.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/gst/gst.c b/gst/gst.c index 30ab9ca..ee9b08f 100644 --- a/gst/gst.c +++ b/gst/gst.c @@ -1125,7 +1125,6 @@ gst_deinit (void) _priv_gst_caps_features_cleanup (); _priv_gst_caps_cleanup (); - _priv_gst_debug_cleanup (); g_type_class_unref (g_type_class_peek (gst_object_get_type ())); g_type_class_unref (g_type_class_peek (gst_pad_get_type ())); @@ -1230,6 +1229,11 @@ gst_deinit (void) gst_deinitialized = TRUE; GST_INFO ("deinitialized GStreamer"); + + /* Doing this as the very last step to allow the above GST_INFO() to work + * correctly. It's of course making the above statement a lie: for a short + * while we're not deinitialized yet */ + _priv_gst_debug_cleanup (); } /** diff --git a/gst/gstinfo.c b/gst/gstinfo.c index 16582e0..2812164 100644 --- a/gst/gstinfo.c +++ b/gst/gstinfo.c @@ -2097,6 +2097,35 @@ _priv_gst_debug_cleanup (void) } g_mutex_unlock (&__dbg_functions_mutex); + + g_mutex_lock (&__cat_mutex); + while (__categories) { + GstDebugCategory *cat = __categories->data; + g_free ((gpointer) cat->name); + g_free ((gpointer) cat->description); + g_slice_free (GstDebugCategory, cat); + __categories = g_slist_delete_link (__categories, __categories); + } + g_mutex_unlock (&__cat_mutex); + + g_mutex_lock (&__level_name_mutex); + while (__level_name) { + LevelNameEntry *level_name_entry = __level_name->data; + g_pattern_spec_free (level_name_entry->pat); + g_slice_free (LevelNameEntry, level_name_entry); + __level_name = g_slist_delete_link (__level_name, __level_name); + } + g_mutex_unlock (&__level_name_mutex); + + g_mutex_lock (&__log_func_mutex); + while (__log_functions) { + LogFuncEntry *log_func_entry = __log_functions->data; + if (log_func_entry->notify) + log_func_entry->notify (log_func_entry->user_data); + g_slice_free (LogFuncEntry, log_func_entry); + __log_functions = g_slist_delete_link (__log_functions, __log_functions); + } + g_mutex_unlock (&__log_func_mutex); } static void -- 2.7.4