Commit dc5a62f7 authored by Mathieu Duponchelle's avatar Mathieu Duponchelle 🐸

gstinfo: clean up function pointer names hashtable

And add strduped function pointer names to the global quark
table, so that they don't get reported as lost by valgrind.

This allows us to use GST_DEBUG when running tests under
valgrind.
parent 41f873fa
......@@ -1125,6 +1125,7 @@ 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 ()));
......
......@@ -142,6 +142,7 @@ G_GNUC_INTERNAL void _priv_gst_date_time_initialize (void);
G_GNUC_INTERNAL void _priv_gst_allocator_cleanup (void);
G_GNUC_INTERNAL void _priv_gst_caps_features_cleanup (void);
G_GNUC_INTERNAL void _priv_gst_caps_cleanup (void);
G_GNUC_INTERNAL void _priv_gst_debug_cleanup (void);
/* called from gst_task_cleanup_all(). */
G_GNUC_INTERNAL void _priv_gst_element_cleanup (void);
......
......@@ -2060,7 +2060,7 @@ _gst_debug_nameof_funcptr (GstDebugFuncPtr func)
* the name */
#ifdef HAVE_DLADDR
if (dladdr ((gpointer) func, &dl_info) && dl_info.dli_sname) {
gchar *name = g_strdup (dl_info.dli_sname);
const gchar *name = g_intern_string (dl_info.dli_sname);
_gst_debug_register_funcptr (func, name);
return name;
......@@ -2068,9 +2068,12 @@ _gst_debug_nameof_funcptr (GstDebugFuncPtr func)
#endif
{
gchar *name = g_strdup_printf ("%p", (gpointer) func);
const gchar *iname = g_intern_string (name);
_gst_debug_register_funcptr (func, name);
return name;
g_free (name);
_gst_debug_register_funcptr (func, iname);
return iname;
}
}
......@@ -2083,8 +2086,22 @@ _gst_debug_register_funcptr (GstDebugFuncPtr func, const gchar * ptrname)
if (!__gst_function_pointers)
__gst_function_pointers = g_hash_table_new (g_direct_hash, g_direct_equal);
if (!g_hash_table_lookup (__gst_function_pointers, ptr))
if (!g_hash_table_lookup (__gst_function_pointers, ptr)) {
g_hash_table_insert (__gst_function_pointers, ptr, (gpointer) ptrname);
}
g_mutex_unlock (&__dbg_functions_mutex);
}
void
_priv_gst_debug_cleanup (void)
{
g_mutex_lock (&__dbg_functions_mutex);
if (__gst_function_pointers) {
g_hash_table_unref (__gst_function_pointers);
__gst_function_pointers = NULL;
}
g_mutex_unlock (&__dbg_functions_mutex);
}
......@@ -2167,6 +2184,11 @@ _gst_debug_nameof_funcptr (GstDebugFuncPtr func)
return "(NULL)";
}
void
_priv_gst_debug_cleanup (void)
{
}
void
gst_debug_log (GstDebugCategory * category, GstDebugLevel level,
const gchar * file, const gchar * function, gint line,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment