Pass the TypeNode to type_data_last_unref_Wm()
authorEdward Hervey <bilboed@bilboed.com>
Thu, 24 Sep 2009 08:16:48 +0000 (10:16 +0200)
committerAlexander Larsson <alexl@redhat.com>
Mon, 30 Nov 2009 19:52:32 +0000 (20:52 +0100)
Previously the GType was looked up just for calling the function
Also moves the unref functions together in the code.

https://bugzilla.gnome.org/show_bug.cgi?id=585375

gobject/gtype.c

index 5945d7f..cd33770 100644 (file)
@@ -187,7 +187,7 @@ static            void                      type_data_make_W                (TypeNode               *node,
 static inline void                     type_data_ref_Wm                (TypeNode               *node);
 static inline void                     type_data_unref_WmREC           (TypeNode               *node,
                                                                         gboolean                uncached);
-static void                            type_data_last_unref_Wm         (GType                   type,
+static void                            type_data_last_unref_Wm         (TypeNode *              node,
                                                                         gboolean                uncached);
 static inline gpointer                 type_get_qdata_L                (TypeNode               *node,
                                                                         GQuark                  quark);
@@ -1201,30 +1201,6 @@ type_data_ref_Wm (TypeNode *node)
     }
 }
 
-static inline void
-type_data_unref_WmREC (TypeNode *node,
-                       gboolean  uncached)
-{
-  g_assert (node->data && node->ref_count);
-  if (node->ref_count > 1)
-    node->ref_count -= 1;
-  else
-    {
-      GType node_type = NODE_TYPE (node);
-      if (!node->plugin)
-       {
-         g_warning ("static type `%s' unreferenced too often",
-                    NODE_NAME (node));
-         return;
-       }
-      G_WRITE_UNLOCK (&type_rw_lock);
-      g_static_rec_mutex_lock (&class_init_rec_mutex); /* required locking order: 1) class_init_rec_mutex, 2) type_rw_lock */
-      G_WRITE_LOCK (&type_rw_lock);
-      type_data_last_unref_Wm (node_type, uncached);
-      g_static_rec_mutex_unlock (&class_init_rec_mutex);
-    }
-}
-
 static gboolean
 iface_node_has_available_offset_L (TypeNode *iface_node,
                                   int offset,
@@ -2272,17 +2248,15 @@ type_data_finalize_class_U (TypeNode  *node,
 }
 
 static void
-type_data_last_unref_Wm (GType    type,
-                        gboolean uncached)
+type_data_last_unref_Wm (TypeNode *node,
+                        gboolean  uncached)
 {
-  TypeNode *node = lookup_type_node_I (type);
-  
   g_return_if_fail (node != NULL && node->plugin != NULL);
   
   if (!node->data || node->ref_count == 0)
     {
       g_warning ("cannot drop last reference to unreferenced type `%s'",
-                type_descriptive_name_I (type));
+                NODE_NAME (node));
       return;
     }
 
@@ -2370,6 +2344,29 @@ type_data_last_unref_Wm (GType    type,
     }
 }
 
+static inline void
+type_data_unref_WmREC (TypeNode *node,
+                       gboolean  uncached)
+{
+  g_assert (node->data && node->ref_count);
+  if (node->ref_count > 1)
+    node->ref_count -= 1;
+  else
+    {
+      if (!node->plugin)
+       {
+         g_warning ("static type `%s' unreferenced too often",
+                    NODE_NAME (node));
+         return;
+       }
+      G_WRITE_UNLOCK (&type_rw_lock);
+      g_static_rec_mutex_lock (&class_init_rec_mutex); /* required locking order: 1) class_init_rec_mutex, 2) type_rw_lock */
+      G_WRITE_LOCK (&type_rw_lock);
+      type_data_last_unref_Wm (node, uncached);
+      g_static_rec_mutex_unlock (&class_init_rec_mutex);
+    }
+}
+
 /**
  * g_type_add_class_cache_func:
  * @cache_data: data to be passed to @cache_func