gst/gstinfo.c: Fix locking order, handle NULL function values properly.
authorTim-Philipp Müller <tim@centricular.net>
Fri, 1 Sep 2006 15:55:20 +0000 (15:55 +0000)
committerTim-Philipp Müller <tim@centricular.net>
Fri, 1 Sep 2006 15:55:20 +0000 (15:55 +0000)
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.

ChangeLog
gst/gstinfo.c
gst/gstinfo.h
gst/gstpad.c

index 6886016..a25c47d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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),
index 70d86eb..9ad91a1 100644 (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 */
index f733d53..dd915d2 100644 (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)
index 525adfe..689a42a 100644 (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);