gst/gstinfo.c: Fix locking order, handle NULL function values properly.

Original commit message from CVS:
* gst/gstinfo.c: (_gst_debug_nameof_funcptr):
Fix locking order, handle NULL function values properly.
* gst/gstinfo.h:
Fix docs.
* gst/gstpad.c: (gst_pad_buffer_alloc_unchecked):
Initialised variable before using it and fix debug statement to
print the address of the function rather than the address of the
variable on the stack holding the address of the function.
This commit is contained in:
Tim-Philipp Müller 2006-09-01 15:55:20 +00:00
parent 1b623c3230
commit 1c389318ec
4 changed files with 27 additions and 6 deletions

View file

@ -1,3 +1,16 @@
2006-09-01 Tim-Philipp Müller <tim at centricular dot net>
* gst/gstinfo.c: (_gst_debug_nameof_funcptr):
Fix locking order, handle NULL function values properly.
* gst/gstinfo.h:
Fix docs.
* gst/gstpad.c: (gst_pad_buffer_alloc_unchecked):
Initialised variable before using it and fix debug statement to
print the address of the function rather than the address of the
variable on the stack holding the address of the function.
2006-09-01 Wim Taymans <wim@fluendo.com>
* gst/gstghostpad.c: (gst_proxy_pad_do_event),

View file

@ -1215,12 +1215,17 @@ _gst_debug_nameof_funcptr (GstDebugFuncPtr ptr)
Dl_info dlinfo;
#endif
if (G_UNLIKELY (func == NULL))
return "(NULL)";
g_static_mutex_lock (&__dbg_functions_mutex);
if (G_LIKELY (__gst_function_pointers)) {
g_static_mutex_lock (&__dbg_functions_mutex);
ptrname = g_hash_table_lookup (__gst_function_pointers, ptr);
g_static_mutex_unlock (&__dbg_functions_mutex);
if (G_LIKELY (ptrname))
return ptrname;
} else {
g_static_mutex_unlock (&__dbg_functions_mutex);
}
/* we need to create an entry in the hash table for this one so we don't leak
* the name */

View file

@ -887,12 +887,13 @@ G_CONST_RETURN gchar *
/**
* GST_DEBUG_FUNCPTR_NAME:
* @ptr: pointer to the function to look up the name
* @ptr: address of the function of which to look up the name
*
* Retrieves the name of the function, if it was previously registered with
* GST_DEBUG_FUNCPTR(). If not, it returns a description of the pointer.
*
* Make sure you free the string after use.
* This macro returns a constant string which must not be modified or
* freed by the caller.
*/
#define GST_DEBUG_FUNCPTR_NAME(ptr) \
_gst_debug_nameof_funcptr((GstDebugFuncPtr)ptr)

View file

@ -2549,22 +2549,24 @@ gst_pad_buffer_alloc_unchecked (GstPad * pad, guint64 offset, gint size,
if (G_UNLIKELY (GST_PAD_IS_FLUSHING (pad)))
goto flushing;
bufferallocfunc = pad->bufferallocfunc;
if (offset == GST_BUFFER_OFFSET_NONE) {
GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad,
"calling bufferallocfunc &%s (@%p) for size %d offset NONE",
GST_DEBUG_FUNCPTR_NAME (bufferallocfunc), &bufferallocfunc, size);
GST_DEBUG_FUNCPTR_NAME (bufferallocfunc), bufferallocfunc, size);
} else {
GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad,
"calling bufferallocfunc &%s (@%p) of for size %d offset %"
G_GUINT64_FORMAT, GST_DEBUG_FUNCPTR_NAME (bufferallocfunc),
&bufferallocfunc, size, offset);
bufferallocfunc, size, offset);
}
GST_OBJECT_UNLOCK (pad);
/* G_LIKELY for now since most elements don't implement a buffer alloc
* function and there is no default alloc proxy function as this is usually
* not possible. */
if (G_LIKELY ((bufferallocfunc = pad->bufferallocfunc) == NULL))
if (G_LIKELY (bufferallocfunc == NULL))
goto fallback;
ret = bufferallocfunc (pad, offset, size, caps, buf);