diff --git a/ChangeLog b/ChangeLog index 6886016c04..a25c47d1c7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2006-09-01 Tim-Philipp Müller + + * 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 * gst/gstghostpad.c: (gst_proxy_pad_do_event), diff --git a/gst/gstinfo.c b/gst/gstinfo.c index 70d86eb4ee..9ad91a10c1 100644 --- a/gst/gstinfo.c +++ b/gst/gstinfo.c @@ -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 */ diff --git a/gst/gstinfo.h b/gst/gstinfo.h index f733d53271..dd915d26c6 100644 --- a/gst/gstinfo.h +++ b/gst/gstinfo.h @@ -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) diff --git a/gst/gstpad.c b/gst/gstpad.c index 525adfe0d8..689a42a46c 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -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);