g_object_[add|remove]_weak_pointer needs an explicit cast



Hi,

I've added this code myself, but have now found that to use 
g_object_[add|remove]_weak_pointer() one has to write code
like

 g_object_add_weak_pointer (G_OBJECT (foo->object),
                            (gpointer *) &foo->object);

since gcc doesn't seem to like the simpler

 g_object_add_weak_pointer (G_OBJECT (foo->object),
                            &foo->object);

I propose we apply the attached simple patch to remove the
need to insert an explicit cast. The name weak_pointer_location
should be clear enough to outline that we expect a pointer to
a pointer location here. Any objections?


Salut, Sven

Index: gobject/gobject.c
===================================================================
RCS file: /cvs/gnome/glib/gobject/gobject.c,v
retrieving revision 1.41
diff -u -r1.41 gobject.c
--- gobject/gobject.c	2001/08/18 03:07:48	1.41
+++ gobject/gobject.c	2001/08/19 12:45:13
@@ -1266,7 +1266,7 @@
 
 void
 g_object_add_weak_pointer (GObject  *object, 
-                           gpointer *weak_pointer_location)
+                           gpointer  weak_pointer_location)
 {
   g_return_if_fail (G_IS_OBJECT (object));
   g_return_if_fail (weak_pointer_location != NULL);
@@ -1278,7 +1278,7 @@
 
 void
 g_object_remove_weak_pointer (GObject  *object, 
-                              gpointer *weak_pointer_location)
+                              gpointer  weak_pointer_location)
 {
   g_return_if_fail (G_IS_OBJECT (object));
   g_return_if_fail (weak_pointer_location != NULL);
Index: gobject/gobject.h
===================================================================
RCS file: /cvs/gnome/glib/gobject/gobject.h,v
retrieving revision 1.18
diff -u -r1.18 gobject.h
--- gobject/gobject.h	2001/08/18 03:07:48	1.18
+++ gobject/gobject.h	2001/08/19 12:45:13
@@ -156,9 +156,9 @@
 					       GWeakNotify     notify,
 					       gpointer	       data);
 void        g_object_add_weak_pointer         (GObject        *object, 
-                                               gpointer       *weak_pointer_location);
+                                               gpointer        weak_pointer_location);
 void        g_object_remove_weak_pointer      (GObject        *object, 
-                                               gpointer       *weak_pointer_location);
+                                               gpointer        weak_pointer_location);
 gpointer    g_object_get_qdata                (GObject        *object,
 					       GQuark          quark);
 void        g_object_set_qdata                (GObject        *object,




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