[glib/halfline/debug-metrics: 7/12] gsignal: add g_signal_name_unlocked helper




commit f6abef85e0cda3a2aaf506c10406abb19602fd3e
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 cd5780518..8437846ea 100644
--- a/gobject/gsignal.c
+++ b/gobject/gsignal.c
@@ -205,6 +205,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 --- */
@@ -1315,6 +1316,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.
@@ -1328,14 +1341,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]