[gnumeric] Calc: fix FMR in collect cache.



commit cabf5230adbeffe2e3ef5c9005e2eeb0a088d31a
Author: Morten Welinder <terra gnome org>
Date:   Mon Aug 16 15:58:19 2010 -0400

    Calc: fix FMR in collect cache.

 ChangeLog     |    2 ++
 NEWS          |    1 +
 src/collect.c |   14 +++++++++++++-
 3 files changed, 16 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index f15f225..e39fd8c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2010-08-16  Morten Welinder  <terra gnome org>
 
+	* src/collect.c (collect_floats): Fix #627079 (FMR).
+
 	* src/complex.c (complex_pow): Special-case a=0 which the general
 	formula bungles.  Fixes #627014.
 
diff --git a/NEWS b/NEWS
index fc912cf..e8d64ee 100644
--- a/NEWS
+++ b/NEWS
@@ -38,6 +38,7 @@ Morten:
 	* Fix win32 random problem.  [#533779]
 	* Fix IMPOWER problem.  [#627014]
 	* Avoid criticals in ODS import.
+	* Fix problem with collect cache.  [#627079]
 
 --------------------------------------------------------------------------
 Gnumeric 1.10.8
diff --git a/src/collect.c b/src/collect.c
index f7e9748..5bc416f 100644
--- a/src/collect.c
+++ b/src/collect.c
@@ -419,6 +419,7 @@ collect_floats (int argc, GnmExprConstPtr const *argv,
 
 	if (key) {
 		SingleFloatsCacheEntry *ce = g_new (SingleFloatsCacheEntry, 1);
+		SingleFloatsCacheEntry *ce2;
 		ce->value = key;
 		ce->flags = keyflags;
 		ce->n = *n;
@@ -431,7 +432,18 @@ collect_floats (int argc, GnmExprConstPtr const *argv,
 		} else
 			ce->data = g_memdup (cl.data, MAX (1, *n) * sizeof (gnm_float));
 		prune_caches ();
-		g_hash_table_insert (single_floats_cache, ce, ce);
+
+		/*
+		 * We looked for the entry earlier and it was not there.
+		 * However, sub-calculation might have added it so be careful
+		 * to adjust sizes and replace the not-so-old entry.
+		 * See bug 627079.
+		 */
+		ce2 = g_hash_table_lookup (single_floats_cache, ce);
+		if (ce2)
+			total_cache_size -= 1 + ce2->n;
+
+		g_hash_table_replace (single_floats_cache, ce, ce);
 		total_cache_size += 1 + *n;
 	}
 	return cl.data;



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