[gnumeric] Solver: plug leak.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Solver: plug leak.
- Date: Wed, 7 Jan 2015 01:19:32 +0000 (UTC)
commit 546d165bea75356d98d13caec78256ec60457d5a
Author: Morten Welinder <terra gnome org>
Date: Tue Jan 6 19:52:13 2015 -0500
Solver: plug leak.
src/tools/ChangeLog | 5 +++++
src/tools/gnm-solver.c | 28 ++++++++++++++++++++++++++--
2 files changed, 31 insertions(+), 2 deletions(-)
---
diff --git a/src/tools/ChangeLog b/src/tools/ChangeLog
index 6b5fc19..5198dcc 100644
--- a/src/tools/ChangeLog
+++ b/src/tools/ChangeLog
@@ -1,3 +1,8 @@
+2015-01-06 Morten Welinder <terra gnome org>
+
+ * gnm-solver.c (gnm_sub_solver_finalize): New function to plug
+ leak.
+
2014-09-25 Morten Welinder <terra gnome org>
* Release 1.12.18
diff --git a/src/tools/gnm-solver.c b/src/tools/gnm-solver.c
index 4c3c539..ac18140 100644
--- a/src/tools/gnm-solver.c
+++ b/src/tools/gnm-solver.c
@@ -1815,8 +1815,11 @@ gnm_sub_solver_clear (GnmSubSolver *subsol)
subsol->program_filename = NULL;
}
- g_hash_table_remove_all (subsol->cell_from_name);
- g_hash_table_remove_all (subsol->name_from_cell);
+ if (subsol->cell_from_name)
+ g_hash_table_remove_all (subsol->cell_from_name);
+
+ if (subsol->name_from_cell)
+ g_hash_table_remove_all (subsol->name_from_cell);
}
static void
@@ -1830,6 +1833,26 @@ gnm_sub_solver_dispose (GObject *obj)
}
static void
+gnm_sub_solver_finalize (GObject *obj)
+{
+ GnmSubSolver *subsol = GNM_SUB_SOLVER (obj);
+
+ /*
+ * The weird finalization in gnm_lpsolve_final makes it important that
+ * we leave the object in a state that gnm_sub_solver_clear is happy
+ * with.
+ */
+
+ g_hash_table_destroy (subsol->cell_from_name);
+ subsol->cell_from_name = NULL;
+
+ g_hash_table_destroy (subsol->name_from_cell);
+ subsol->name_from_cell = NULL;
+
+ gnm_sub_solver_parent_class->finalize (obj);
+}
+
+static void
gnm_sub_solver_init (GnmSubSolver *subsol)
{
int i;
@@ -2088,6 +2111,7 @@ gnm_sub_solver_class_init (GObjectClass *object_class)
gnm_sub_solver_parent_class = g_type_class_peek_parent (object_class);
object_class->dispose = gnm_sub_solver_dispose;
+ object_class->finalize = gnm_sub_solver_finalize;
}
GSF_CLASS (GnmSubSolver, gnm_sub_solver,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]