r15833 - gnucash/trunk/src/gnome-utils - Normalize memory handling of GncDenseCal marked-element "info" string.

Josh Sled jsled at cvs.gnucash.org
Thu Apr 5 20:54:52 EDT 2007


Author: jsled
Date: 2007-04-05 20:54:52 -0400 (Thu, 05 Apr 2007)
New Revision: 15833
Trac: http://svn.gnucash.org/trac/changeset/15833

Modified:
   gnucash/trunk/src/gnome-utils/gnc-dense-cal-store.c
   gnucash/trunk/src/gnome-utils/gnc-dense-cal.c
   gnucash/trunk/src/gnome-utils/gnc-sx-instance-dense-cal-adapter.c
Log:
Normalize memory handling of GncDenseCal marked-element "info" string.


Modified: gnucash/trunk/src/gnome-utils/gnc-dense-cal-store.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-dense-cal-store.c	2007-04-06 00:51:42 UTC (rev 15832)
+++ gnucash/trunk/src/gnome-utils/gnc-dense-cal-store.c	2007-04-06 00:54:52 UTC (rev 15833)
@@ -289,7 +289,7 @@
 {
     GncDenseCalStore *mdl = GNC_DENSE_CAL_STORE(model);
     // assert(tag == 1)
-    return mdl->info;
+    return g_strdup(mdl->info);
 }
 
 static gint

Modified: gnucash/trunk/src/gnome-utils/gnc-dense-cal.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-dense-cal.c	2007-04-06 00:51:42 UTC (rev 15832)
+++ gnucash/trunk/src/gnome-utils/gnc-dense-cal.c	2007-04-06 00:54:52 UTC (rev 15833)
@@ -1660,7 +1660,7 @@
     num_marks = gnc_dense_cal_model_get_instance_count(cal->model, tag);
 
     if (num_marks == 0)
-        return;
+        goto cleanup;
 
     dates = g_new0(GDate*, num_marks);
     for (idx = 0; idx < num_marks; idx++)
@@ -1676,6 +1676,9 @@
         g_date_free(dates[idx]);
     }
     g_free(dates);
+
+cleanup:
+    g_free(info);
 }
 
 static void
@@ -1688,6 +1691,7 @@
         guint tag = GPOINTER_TO_UINT(tags->data);
         gdc_add_tag_markings(cal, tag);
     }
+    // @fixme: list cleanup
 }
 
 static void
@@ -1700,6 +1704,7 @@
         guint tag = GPOINTER_TO_UINT(tags->data);
         gdc_mark_remove(cal, tag);
     }
+    // @fixme: list cleanup
 }
 
 static void

Modified: gnucash/trunk/src/gnome-utils/gnc-sx-instance-dense-cal-adapter.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-sx-instance-dense-cal-adapter.c	2007-04-06 00:51:42 UTC (rev 15832)
+++ gnucash/trunk/src/gnome-utils/gnc-sx-instance-dense-cal-adapter.c	2007-04-06 00:54:52 UTC (rev 15833)
@@ -206,7 +206,6 @@
     // g_list_find(instances->sxes, {sx_to_tag, tag}).get_freq_spec().get_freq_str();
     FreqSpec *spec;
     GString *info;
-    gchar *info_str;
     GncSxInstances *insts
         = (GncSxInstances*)g_list_find_custom(adapter->instances->sx_instance_list, GUINT_TO_POINTER(tag), gsidca_find_sx_with_tag)->data;
     if (insts == NULL)
@@ -214,9 +213,7 @@
     spec = xaccSchedXactionGetFreqSpec(insts->sx);
     info = g_string_sized_new(16);
     xaccFreqSpecGetFreqStr(spec, info);
-    info_str = info->str; // @fixme leaked... :/
-    g_string_free(info, FALSE);
-    return info_str;
+    return g_string_free(info, FALSE);
 }
 
 static gint



More information about the gnucash-changes mailing list