[gnumeric] xlsx: plug leaks.



commit c1eeea7b1cd744da03a1ad218e02fefb66cc0da2
Author: Morten Welinder <terra gnome org>
Date:   Fri Apr 10 15:11:23 2015 -0400

    xlsx: plug leaks.

 plugins/excel/ChangeLog             |    7 +++++++
 plugins/excel/ms-excel-util.c       |   33 +++++++++++++++++++++++++++++++++
 plugins/excel/ms-excel-util.h       |    4 ++++
 plugins/excel/ms-excel-write.c      |   25 -------------------------
 plugins/excel/ms-excel-write.h      |    2 --
 plugins/excel/xlsx-write-docprops.c |    2 ++
 plugins/excel/xlsx-write.c          |    2 +-
 7 files changed, 47 insertions(+), 28 deletions(-)
---
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index 9f123a0..422df59 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,3 +1,10 @@
+2015-04-10  Morten Welinder  <terra gnome org>
+
+       * ms-excel-util.c (xls_collect_hlinks): Rename from
+       excel_collect_hlinks.  Move from-ms-excel-write.c.  Plug leak.
+
+       * xlsx-write-docprops.c (xlsx_map_to_date_core): Plug leaks.
+
 2015-04-06  Morten Welinder  <terra gnome org>
 
        * xlsx-write-drawing.c (xlsx_write_one_plot): Always write series'
diff --git a/plugins/excel/ms-excel-util.c b/plugins/excel/ms-excel-util.c
index f48aeb9..b5a6ba0 100644
--- a/plugins/excel/ms-excel-util.c
+++ b/plugins/excel/ms-excel-util.c
@@ -17,6 +17,9 @@
 #include "ms-excel-util.h"
 #include <goffice/goffice.h>
 #include <glib/gi18n-lib.h>
+#include <hlink.h>
+#include <sheet-style.h>
+#include <ranges.h>
 
 #include <string.h>
 
@@ -906,3 +909,33 @@ xls_arrow_from_xl (GOArrow *arrow, double width, XLArrowType typ, int l, int w)
 }
 
 /*****************************************************************************/
+
+GHashTable *
+xls_collect_hlinks (GnmStyleList *sl, int max_col, int max_row)
+{
+       GHashTable *group = g_hash_table_new_full
+               (g_direct_hash, g_direct_equal, NULL, (GDestroyNotify)g_slist_free);
+
+       for (; sl != NULL ; sl = sl->next) {
+               GnmStyleRegion const *sr = sl->data;
+               GnmHLink   *hlink;
+               GSList     *ranges;
+
+               /* Clip here to avoid creating a DV record if there are no regions */
+               if (sr->range.start.col >= max_col ||
+                   sr->range.start.row >= max_row) {
+                       range_dump (&sr->range, "bounds drop\n");
+                       continue;
+               }
+               hlink  = gnm_style_get_hlink (sr->style);
+               ranges = g_hash_table_lookup (group, hlink);
+               if (ranges)
+                       g_hash_table_steal (group, hlink);
+               g_hash_table_insert (group, hlink,
+                                    g_slist_prepend (ranges, (gpointer)&sr->range));
+       }
+
+       return group;
+}
+
+/*****************************************************************************/
diff --git a/plugins/excel/ms-excel-util.h b/plugins/excel/ms-excel-util.h
index 8d512af..9cd0341 100644
--- a/plugins/excel/ms-excel-util.h
+++ b/plugins/excel/ms-excel-util.h
@@ -123,4 +123,8 @@ void xls_arrow_from_xl (GOArrow *arrow, double width,
 
 /*****************************************************************************/
 
+GHashTable *xls_collect_hlinks (GnmStyleList *sl, int max_col, int max_row);
+
+/*****************************************************************************/
+
 #endif /* GNM_MS_EXCEL_UTIL_H */
diff --git a/plugins/excel/ms-excel-write.c b/plugins/excel/ms-excel-write.c
index cc2ab5c..719cc30 100644
--- a/plugins/excel/ms-excel-write.c
+++ b/plugins/excel/ms-excel-write.c
@@ -6862,31 +6862,6 @@ excel_collect_validations (GnmStyleList *ptr, int max_col, int max_row)
 }
 
 GHashTable *
-excel_collect_hlinks (GnmStyleList *ptr, int max_col, int max_row)
-{
-       GnmStyleRegion const *sr;
-       GnmHLink   *hlink;
-       GSList     *ranges;
-       GHashTable *group = g_hash_table_new (g_direct_hash, g_direct_equal);
-
-       for (; ptr != NULL ; ptr = ptr->next) {
-               sr = ptr->data;
-               /* Clip here to avoid creating a DV record if there are no regions */
-               if (sr->range.start.col >= max_col ||
-                   sr->range.start.row >= max_row) {
-                       range_dump (&sr->range, "bounds drop\n");
-                       continue;
-               }
-               hlink  = gnm_style_get_hlink (sr->style);
-               ranges = g_hash_table_lookup (group, hlink);
-               g_hash_table_replace (group, hlink,
-                       g_slist_prepend (ranges, (gpointer)&sr->range));
-       }
-
-       return group;
-}
-
-GHashTable *
 excel_collect_pivot_caches (Workbook const *wb)
 {
        GSList *slicers;
diff --git a/plugins/excel/ms-excel-write.h b/plugins/excel/ms-excel-write.h
index 32862b9..b274bce 100644
--- a/plugins/excel/ms-excel-write.h
+++ b/plugins/excel/ms-excel-write.h
@@ -166,8 +166,6 @@ typedef struct {
 } XLValInputPair;
 GHashTable *excel_collect_validations  (GnmStyleList *ptr,
                                        int max_col, int max_row);
-GHashTable *excel_collect_hlinks       (GnmStyleList *ptr,
-                                       int max_col, int max_row);
 GHashTable *excel_collect_pivot_caches (Workbook const *wb);
 
 void excel_sheet_extent (Sheet const *sheet, GnmRange *extent, GnmStyle **col_styles,
diff --git a/plugins/excel/xlsx-write-docprops.c b/plugins/excel/xlsx-write-docprops.c
index 41b8be1..9f2acd4 100644
--- a/plugins/excel/xlsx-write-docprops.c
+++ b/plugins/excel/xlsx-write-docprops.c
@@ -99,6 +99,7 @@ xlsx_map_to_date_core (GsfXMLOut *output, GValue const *val)
                str = gsf_timestamp_as_string (ts);
                gsf_xml_out_add_cstr (output, NULL, str);
                g_free (str);
+               gsf_timestamp_free (ts);
        } else {
                GsfTimestamp * ts = gsf_timestamp_new ();
                char *str;
@@ -109,6 +110,7 @@ xlsx_map_to_date_core (GsfXMLOut *output, GValue const *val)
                str = gsf_timestamp_as_string (ts);
                gsf_xml_out_add_cstr (output, NULL, str);
                g_free (str);
+               gsf_timestamp_free (ts);
        }
 }
 
diff --git a/plugins/excel/xlsx-write.c b/plugins/excel/xlsx-write.c
index 9a1e02b..b00c927 100644
--- a/plugins/excel/xlsx-write.c
+++ b/plugins/excel/xlsx-write.c
@@ -2085,7 +2085,7 @@ xlsx_write_hlinks (XLSXWriteState *state, GsfXMLOut *xml, G_GNUC_UNUSED GnmRange
                XLSXClosure info = { state, xml };
                /* filter on logical max, not extent.  XL allows validations
                 * past the stated dimension */
-               GHashTable *group = excel_collect_hlinks (hlinks,
+               GHashTable *group = xls_collect_hlinks (hlinks,
                        XLSX_MAX_COLS, XLSX_MAX_ROWS);
 
                gsf_xml_out_start_element (xml, "hyperlinks");


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