r15899 - gnucash/trunk/src/app-utils - Fix variable name corruption due to merge-update.

Josh Sled jsled at cvs.gnucash.org
Sun Apr 15 13:06:14 EDT 2007


Author: jsled
Date: 2007-04-15 13:06:14 -0400 (Sun, 15 Apr 2007)
New Revision: 15899
Trac: http://svn.gnucash.org/trac/changeset/15899

Modified:
   gnucash/trunk/src/app-utils/gnc-sx-instance-model.c
Log:
Fix variable name corruption due to merge-update.


Modified: gnucash/trunk/src/app-utils/gnc-sx-instance-model.c
===================================================================
--- gnucash/trunk/src/app-utils/gnc-sx-instance-model.c	2007-04-15 16:18:52 UTC (rev 15898)
+++ gnucash/trunk/src/app-utils/gnc-sx-instance-model.c	2007-04-15 17:06:14 UTC (rev 15899)
@@ -131,7 +131,7 @@
 gnc_sx_variable_new(gchar *name)
 {
     GncSxVariable *var = g_new0(GncSxVariable, 1);
-    var->name = name;
+    var->name = g_strdup(name);
     var->value = gnc_numeric_error(GNC_ERROR_ARG);
     var->editable = TRUE;
     return var;
@@ -146,6 +146,22 @@
     return var;
 }
 
+static GncSxVariable*
+gnc_sx_variable_new_copy(GncSxVariable *to_copy)
+{
+    GncSxVariable *var = gnc_sx_variable_new(to_copy->name);
+    var->value = to_copy->value;
+    var->editable = to_copy->editable;
+    return var;
+}
+
+void
+gnc_sx_variable_free(GncSxVariable *var)
+{
+    g_free(var->name);
+    g_free(var);
+}
+
 static gint
 _get_vars_helper(Transaction *txn, void *var_hash_data)
 {
@@ -257,23 +273,7 @@
                                        | GNC_RND_FLOOR);
 }
 
-static GncSxVariable*
-gnc_sx_variable_new_copy(GncSxVariable *to_copy)
-{
-    GncSxVariable *var = gnc_sx_variable_new(to_copy->name);
-    var->value = to_copy->value;
-    var->editable = to_copy->editable;
-    return var;
-}
-
 void
-gnc_sx_variable_free(GncSxVariable *var)
-{
-    // g_free(var->name);
-    g_free(var);
-}
-
-void
 gnc_sx_randomize_variables(GHashTable *vars)
 {
     g_hash_table_foreach(vars, (GHFunc)_set_var_to_random_value, NULL);
@@ -301,13 +301,15 @@
 
     if (! parent->variable_names_parsed)
     {
-        parent->variable_names = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
+        parent->variable_names = g_hash_table_new_full(
+            g_str_hash, g_str_equal, g_free, (GDestroyNotify)gnc_sx_variable_free);
         gnc_sx_get_variables(parent->sx, parent->variable_names);
         g_hash_table_foreach(parent->variable_names, (GHFunc)_wipe_parsed_sx_var, NULL);
         parent->variable_names_parsed = TRUE;
     }
 
-    rtn->variable_bindings = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
+    rtn->variable_bindings = g_hash_table_new_full(
+        g_str_hash, g_str_equal, NULL, (GDestroyNotify)gnc_sx_variable_free);
     g_hash_table_foreach(parent->variable_names, _clone_sx_var_hash_entry, rtn->variable_bindings);
 
     {



More information about the gnucash-changes mailing list