diff --git a/ChangeLog b/ChangeLog index b15c750caa..263eff4903 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2001-05-28 Dave Peticolas + + * src/engine/gnc-pricedb.c (compare_prices_by_date): stabilize + sort using guids + + * src/engine/gnc-pricedb-xml-v1.c (price_parse_xml_sub_node): fix + mem leak + 2001-05-27 Christian Stimming * src/scm/tip-list.scm: edited some tips after consultation with diff --git a/src/engine/gnc-pricedb-xml-v1.c b/src/engine/gnc-pricedb-xml-v1.c index 5113a2613d..773fc34d7a 100644 --- a/src/engine/gnc-pricedb-xml-v1.c +++ b/src/engine/gnc-pricedb-xml-v1.c @@ -98,6 +98,7 @@ price_parse_xml_sub_node(GNCPrice *p, xmlNodePtr sub_node) GUID *c = dom_tree_to_guid(sub_node); if(!c) return FALSE; gnc_price_set_guid(p, c); + g_free(c); } else if(safe_strcmp("price:commodity", sub_node->name) == 0) { gnc_commodity *c = dom_tree_to_commodity_ref(sub_node); if(!c) return FALSE; diff --git a/src/engine/gnc-pricedb.c b/src/engine/gnc-pricedb.c index 113f6194a9..a7c87e6624 100644 --- a/src/engine/gnc-pricedb.c +++ b/src/engine/gnc-pricedb.c @@ -362,6 +362,8 @@ compare_prices_by_date(gconstpointer a, gconstpointer b) { Timespec time_a; Timespec time_b; + gint result; + if(!a && !b) return 0; /* nothing is always less than something */ if(!a) return -1; @@ -369,7 +371,12 @@ compare_prices_by_date(gconstpointer a, gconstpointer b) time_a = gnc_price_get_time((GNCPrice *) a); time_b = gnc_price_get_time((GNCPrice *) b); - return -timespec_cmp(&time_a, &time_b); + result = -timespec_cmp(&time_a, &time_b); + if (result) return result; + + /* For a stable sort */ + return guid_compare (gnc_price_get_guid((GNCPrice *) a), + gnc_price_get_guid((GNCPrice *) b)); } gboolean