[gnumeric] stf: minor memory usage reduction.



commit a89e39fee86e6d9a0e051bd8a15206fe5d0dae78
Author: Morten Welinder <terra gnome org>
Date:   Tue Mar 8 12:43:39 2011 -0500

    stf: minor memory usage reduction.

 ChangeLog       |    8 +++++++-
 src/stf-parse.c |   14 +++++++++-----
 2 files changed, 16 insertions(+), 6 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 0322ee3..3471410 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,13 @@
+2011-03-08  Morten Welinder  <terra gnome org>
+
+	* src/stf-parse.c (stf_parse_sheet): Delete lines as we are done
+	with them.
+	(stf_parse_general_free): Handle freed lines.
+
 2011-03-07  Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* src/sheet-control-gui.c (scg_cursor_move): check one row at a time.
-	
+
 2011-03-04  Morten Welinder  <terra gnome org>
 
 	* src/parse-util.c (std_external_wb): New function.
diff --git a/src/stf-parse.c b/src/stf-parse.c
index 0e3f470..4db0391 100644
--- a/src/stf-parse.c
+++ b/src/stf-parse.c
@@ -792,8 +792,9 @@ stf_parse_general_free (GPtrArray *lines)
 	unsigned lineno;
 	for (lineno = 0; lineno < lines->len; lineno++) {
 		GPtrArray *line = g_ptr_array_index (lines, lineno);
-		/* Fields are not free here.  */
-		g_ptr_array_free (line, TRUE);
+		/* Fields are not freed here.  */
+		if (line)
+			g_ptr_array_free (line, TRUE);
 	}
 	g_ptr_array_free (lines, TRUE);
 }
@@ -1311,12 +1312,15 @@ stf_parse_sheet (StfParseOptions_t *parseoptions,
 			}
 			col++;
 		}
+
+		g_ptr_array_index (lines, lrow) = NULL;
+		g_ptr_array_free (line, TRUE);
 	}
 	END_LOCALE_SWITCH;
 
 	for (lcol = 0, col = start_col;
 	     lcol < parseoptions->col_import_array_len  && col < gnm_sheet_get_max_cols (sheet);
-	     lcol++)
+	     lcol++) {
 		if (parseoptions->col_import_array == NULL ||
 		    parseoptions->col_import_array_len <= lcol ||
 		    parseoptions->col_import_array[lcol]) {
@@ -1329,11 +1333,11 @@ stf_parse_sheet (StfParseOptions_t *parseoptions,
 			}
 			col++;
 		}
+	}
 
-
+	g_string_chunk_free (lines_chunk);
 	if (lines)
 		stf_parse_general_free (lines);
-	g_string_chunk_free (lines_chunk);
 	if (result)
 		stf_read_remember_settings (sheet->workbook, parseoptions);
 	return result;



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