info: Free some more memory on gst_deinit()
authorSebastian Dröge <sebastian@centricular.com>
Sun, 14 Jul 2019 19:41:56 +0000 (22:41 +0300)
committerSebastian Dröge <sebastian@centricular.com>
Mon, 15 Jul 2019 08:35:07 +0000 (11:35 +0300)
gst/gst.c
gst/gstinfo.c

index 30ab9ca..ee9b08f 100644 (file)
--- 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 ();
 }
 
 /**
index 16582e0..2812164 100644 (file)
@@ -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