[glib/halfline/debug-metrics: 4/9] gsignal: add g_signal_name_unlocked helper




commit 495605dae0de98ca6e5f3d802176915404aa275f
Author: Ray Strode <rstrode redhat com>
Date:   Wed May 26 23:45:04 2021 -0400

    gsignal: add g_signal_name_unlocked helper
    
    This function fetches the name of a signal from its id.
    It's like g_signal_name, but works when the signal lock is held.

 gobject/gsignal.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)
---
diff --git a/gobject/gsignal.c b/gobject/gsignal.c
index fa7d9b274..1c5f5ee87 100644
--- a/gobject/gsignal.c
+++ b/gobject/gsignal.c
@@ -204,6 +204,7 @@ static       void               invalid_closure_notify  (gpointer         data,
 static const gchar *            type_debug_name         (GType            type);
 static void                     node_check_deprecated   (const SignalNode *node);
 static void                     node_update_single_va_closure (SignalNode *node);
+static const gchar             *g_signal_name_unlocked (guint signal_id);
 
 
 /* --- structures --- */
@@ -1314,6 +1315,18 @@ g_signal_list_ids (GType  itype,
   return (guint*) g_array_free (result, FALSE);
 }
 
+static const gchar *
+g_signal_name_unlocked (guint signal_id)
+{
+  SignalNode *node;
+  const gchar *name;
+
+  node = LOOKUP_SIGNAL_NODE (signal_id);
+  name = node ? node->name : NULL;
+
+  return (char*) name;
+}
+
 /**
  * g_signal_name:
  * @signal_id: the signal's identifying number.
@@ -1327,14 +1340,12 @@ g_signal_list_ids (GType  itype,
 const gchar *
 g_signal_name (guint signal_id)
 {
-  SignalNode *node;
   const gchar *name;
-  
+
   SIGNAL_LOCK ();
-  node = LOOKUP_SIGNAL_NODE (signal_id);
-  name = node ? node->name : NULL;
+  name = g_signal_name_unlocked (signal_id);
   SIGNAL_UNLOCK ();
-  
+
   return (char*) name;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]