[gnumeric] avoid use of statis variable to hold hash in formula import translation
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] avoid use of statis variable to hold hash in formula import translation
- Date: Sat, 22 Jun 2013 17:56:11 +0000 (UTC)
commit 4e2f440b7b9e6a0bb09190b1ac683300646bbc6d
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Sat Jun 22 11:54:23 2013 -0600
avoid use of statis variable to hold hash in formula import translation
2013-06-22 Andreas J. Guelzow <aguelzow pyrshep ca>
* openoffice-read.c (_OOParseState): add fields
(oo_func_map_in): do not use static variables for the hash
(openoffice_file_open): initialize and free new fields
plugins/openoffice/ChangeLog | 6 ++++++
plugins/openoffice/openoffice-read.c | 26 ++++++++++++++++++++------
2 files changed, 26 insertions(+), 6 deletions(-)
---
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 70dda4d..f54cc8e 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,9 @@
+2013-06-22 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * openoffice-read.c (_OOParseState): add fields
+ (oo_func_map_in): do not use static variables for the hash
+ (openoffice_file_open): initialize and free new fields
+
2013-06-21 Morten Welinder <terra gnome org>
* openoffice-read.c (odf_validation_free): Plug leak.
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 6bbe1ce..66842ea 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -448,6 +448,8 @@ struct _OOParseState {
GnmFilter *filter;
GnmConventions *convs[NUM_FORMULAE_SUPPORTED];
+ GHashTable *openformula_namemap;
+ GHashTable *openformula_handlermap;
struct {
struct {
@@ -11743,23 +11745,27 @@ oo_func_map_in (GnmConventions const *convs, Workbook *scope,
};
static char const OOoAnalysisPrefix[] = "com.sun.star.sheet.addin.Analysis.get";
static char const GnumericPrefix[] = "ORG.GNUMERIC.";
- static GHashTable *namemap = NULL;
- static GHashTable *handlermap = NULL;
GnmFunc *f;
char const *new_name;
int i;
GnmExpr const * (*handler) (GnmConventions const *convs, Workbook *scope, GnmExprList *args);
+ ODFConventions *oconv = (ODFConventions *)convs;
+ GHashTable *namemap;
+ GHashTable *handlermap;
- if (NULL == namemap) {
+ if (NULL == oconv->state->openformula_namemap) {
namemap = g_hash_table_new (go_ascii_strcase_hash,
go_ascii_strcase_equal);
for (i = 0; sc_func_renames[i].oo_name; i++)
g_hash_table_insert (namemap,
(gchar *) sc_func_renames[i].oo_name,
(gchar *) sc_func_renames[i].gnm_name);
- }
- if (NULL == handlermap) {
+ oconv->state->openformula_namemap = namemap;
+ } else
+ namemap = oconv->state->openformula_namemap;
+
+ if (NULL == oconv->state->openformula_handlermap) {
guint i;
handlermap = g_hash_table_new (go_ascii_strcase_hash,
go_ascii_strcase_equal);
@@ -11767,7 +11773,9 @@ oo_func_map_in (GnmConventions const *convs, Workbook *scope,
g_hash_table_insert (handlermap,
(gchar *) sc_func_handlers[i].gnm_name,
sc_func_handlers[i].handler);
- }
+ oconv->state->openformula_handlermap = handlermap;
+ } else
+ handlermap = oconv->state->openformula_handlermap;
handler = g_hash_table_lookup (handlermap, name);
if (handler != NULL) {
@@ -12009,6 +12017,8 @@ openoffice_file_open (G_GNUC_UNUSED GOFileOpener const *fo, GOIOContext *io_cont
state.sheet_order = NULL;
for (i = 0; i<NUM_FORMULAE_SUPPORTED; i++)
state.convs[i] = NULL;
+ state.openformula_namemap = NULL;
+ state.openformula_handlermap = NULL;
state.cur_format.accum = NULL;
state.cur_format.percentage = FALSE;
state.filter = NULL;
@@ -12188,6 +12198,10 @@ openoffice_file_open (G_GNUC_UNUSED GOFileOpener const *fo, GOIOContext *io_cont
g_hash_table_destroy (state.validations);
g_hash_table_destroy (state.strings);
g_hash_table_destroy (state.chart.arrow_markers);
+ if (state.openformula_namemap)
+ g_hash_table_destroy (state.openformula_namemap);
+ if (state.openformula_handlermap)
+ g_hash_table_destroy (state.openformula_handlermap);
g_object_unref (contents);
gnm_expr_sharer_destroy (state.sharer);
g_free (state.chart.cs_enhanced_path);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]