[gnumeric] Cells: use slice allocator, not g_new, for better behaviour.



commit de42758464370d8859d4b51b2d54361c8c6bce98
Author: Morten Welinder <terra gnome org>
Date:   Thu Mar 10 09:58:56 2011 -0500

    Cells: use slice allocator, not g_new, for better behaviour.

 ChangeLog   |   10 +++++++++-
 src/sheet.c |   12 +++++++++---
 2 files changed, 18 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index f0defa6..5d4a506 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,10 +1,18 @@
+2011-03-10  Morten Welinder  <terra gnome org>
+
+	* src/sheet.c (cell_new, cell_free): Use slice allocator, not
+	g_new.
+
 2011-03-08  Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* src/sheet.c: formulas -> formulæ
 	* src/wbc-gtk-actions.c: formulas -> formulæ
-	
+
 2011-03-08  Morten Welinder  <terra gnome org>
 
+	* src/gutils.c (gnm_insert_meta_date): Use GsfTimestamp, not
+	string.
+
 	* src/stf-parse.c (stf_parse_sheet): Delete lines as we are done
 	with them.
 	(stf_parse_general_free): Handle freed lines.
diff --git a/src/sheet.c b/src/sheet.c
index 77fe6f4..65bba03 100644
--- a/src/sheet.c
+++ b/src/sheet.c
@@ -3788,11 +3788,13 @@ sheet_cell_add_to_hash (Sheet *sheet, GnmCell *cell)
 		cell->base.flags |= GNM_CELL_IS_MERGED;
 }
 
-#define USE_CELL_POOL
+#undef USE_CELL_POOL
 
 #ifdef USE_CELL_POOL
 /* The pool from which all cells are allocated.  */
 static GOMemChunk *cell_pool;
+#else
+static int cell_allocations = 0;
 #endif
 
 static GnmCell *
@@ -3802,7 +3804,7 @@ cell_new (void)
 #ifdef USE_CELL_POOL
 		go_mem_chunk_alloc0 (cell_pool)
 #else
-		g_new0 (GnmCell, 1)
+		(cell_allocations++, g_slice_new0 (GnmCell))
 #endif
 	;
 
@@ -3820,7 +3822,7 @@ cell_free (GnmCell *cell)
 #ifdef USE_CELL_POOL
 	go_mem_chunk_free (cell_pool, cell);
 #else
-	g_free (cell);
+	cell_allocations--, g_slice_free1 (sizeof (*cell), cell);
 #endif
 }
 
@@ -3850,8 +3852,12 @@ gnm_sheet_cell_shutdown (void)
 	go_mem_chunk_foreach_leak (cell_pool, cb_cell_pool_leak, NULL);
 	go_mem_chunk_destroy (cell_pool, FALSE);
 	cell_pool = NULL;
+#else
+	if (cell_allocations)
+		g_printerr ("Leaking %d cells.\n", cell_allocations);
 #endif
 }
+
 /****************************************************************************/
 
 /**



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