GtkTooltipsData as memchunks



Hi,

I just looked at the TODO list from GTK+ and the first thing that I 
noticed was that GtkTooltipsData should be allocated with memchunks so 
that's what I did. I switched the allocation strategy for GtkTooltipsData 
to use GMemChunk's. The area_size is 256*sizeof(GtkTooltipsData) which 
might be way too much for tooltips but I figured better safe than sorry. 
I also filled a bugzilla report under bug #50619 , I'm not sure if that's 
OK. Should one mail patches to the devel list, besides filling a bugzilla 
report? If not, then please try not to beat me silly.

Zack Rusin

-- 
43rd Law of Computing: Anything that can go wr
fortune: Segmentation violation -- Core dumped
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtk+/ChangeLog,v
retrieving revision 1.3080
diff -u -3 -p -u -r1.3080 ChangeLog
--- ChangeLog	2002/02/23 07:56:40	1.3080
+++ ChangeLog	2002/02/24 07:19:17
@@ -1,3 +1,7 @@
+Sun Feb 24 02:02:57 2002  Zack Rusin  <zackxd psu edu>
+
+	* gtk/gtktooltips.c: allocate GtkTooltipsData from memchunks
+
 2002-02-23  Jody Goldberg <jody gnome org>
 
 	* gtk/gtkaccelgroup.c (gtk_accel_group_connect) : lower case the
Index: TODO
===================================================================
RCS file: /cvs/gnome/gtk+/TODO,v
retrieving revision 1.66
diff -u -3 -p -u -r1.66 TODO
--- TODO	2000/02/29 13:15:08	1.66
+++ TODO	2002/02/24 07:19:18
@@ -6,8 +6,6 @@ Outstanding items:
  * implement gtk_default_draw_oval and other missing things in gtkstyle.c.
  
  * enforce invariants on *_RESIZE* and *_REDRAW* flags.
-
- * GtkToolTips: allocate GtkTooltipsData from memchunks
                           
  * Make all widget attributes configurable after the widget is created (timj).
  
Index: gtk/gtktooltips.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtktooltips.c,v
retrieving revision 1.48
diff -u -3 -p -u -r1.48 gtktooltips.c
--- gtk/gtktooltips.c	2002/02/14 05:18:44	1.48
+++ gtk/gtktooltips.c	2002/02/24 07:19:23
@@ -67,6 +67,9 @@ static gboolean get_keyboard_mode       
 static GtkObjectClass *parent_class;
 static const gchar  *tooltips_data_key = "_GtkTooltipsData";
 
+/* Memory Management. */
+static GMemChunk  *tips_mem_chunk    = NULL;
+
 GtkType
 gtk_tooltips_get_type (void)
 {
@@ -109,7 +112,13 @@ gtk_tooltips_init (GtkTooltips *tooltips
   tooltips->tip_window = NULL;
   tooltips->active_tips_data = NULL;
   tooltips->tips_data_list = NULL;
-  
+
+  if (!tips_mem_chunk)
+    tips_mem_chunk = g_mem_chunk_new ("TooltipsData",
+				      sizeof (GtkTooltipsData),
+				      256 * sizeof (GtkTooltipsData),
+				      G_ALLOC_AND_FREE);
+
   tooltips->delay = DEFAULT_DELAY;
   tooltips->enabled = TRUE;
   tooltips->timer_tag = 0;
@@ -133,7 +142,7 @@ gtk_tooltips_destroy_data (GtkTooltipsDa
  				 (gpointer) tooltipsdata);
   gtk_object_remove_data (GTK_OBJECT (tooltipsdata->widget), tooltips_data_key);
   gtk_widget_unref (tooltipsdata->widget);
-  g_free (tooltipsdata);
+  g_mem_chunk_free (tips_mem_chunk, tooltipsdata);
 }
 
 static void
@@ -272,7 +281,7 @@ gtk_tooltips_set_tip (GtkTooltips *toolt
       if (tooltipsdata)
         gtk_tooltips_widget_remove (tooltipsdata->widget, tooltipsdata);
       
-      tooltipsdata = g_new0 (GtkTooltipsData, 1);
+      tooltipsdata = g_chunk_new0 (GtkTooltipsData, tips_mem_chunk);
       
       tooltipsdata->tooltips = tooltips;
       tooltipsdata->widget = widget;


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