[goffice] avoid keeping GOFormats just in the style_format_hash
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] avoid keeping GOFormats just in the style_format_hash
- Date: Thu, 8 Sep 2011 19:14:24 +0000 (UTC)
commit 35288b3fe6a331bd863be5ceb78bd9189e3b5a93
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Thu Sep 8 13:13:14 2011 -0600
avoid keeping GOFormats just in the style_format_hash
2011-09-08 Andreas J. Guelzow <aguelzow pyrshep ca>
* goffice/utils/go-format.c (go_format_refcount_cb): deleted
(go_format_foreach): just wrap the GHFunc
(go_format_unref): don't keep GOFormats that are just in the hash
ChangeLog | 6 ++++++
goffice/utils/go-format.c | 28 ++++++++++------------------
2 files changed, 16 insertions(+), 18 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 9ba5baa..198b352 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2011-09-08 Andreas J. Guelzow <aguelzow pyrshep ca>
+ * goffice/utils/go-format.c (go_format_refcount_cb): deleted
+ (go_format_foreach): just wrap the GHFunc
+ (go_format_unref): don't keep GOFormats that are just in the hash
+
+2011-09-08 Andreas J. Guelzow <aguelzow pyrshep ca>
+
* goffice/utils/go-format.h (go_format_set_build_in): deleted again
(go_format_is_build_in): deleted again
* goffice/utils/go-format.c (go_format_set_build_in): deleted again
diff --git a/goffice/utils/go-format.c b/goffice/utils/go-format.c
index a192ed7..a20e899 100644
--- a/goffice/utils/go-format.c
+++ b/goffice/utils/go-format.c
@@ -578,27 +578,12 @@ static long double beyond_precisionl;
/* WARNING : Global */
static GHashTable *style_format_hash = NULL;
-typedef struct {
- GHFunc func;
- gpointer user_data;
-} _go_format_foreach_t;
-
-static void
-go_format_refcount_cb (char *key, GOFormat *fmt,
- _go_format_foreach_t *cl)
-{
- if (fmt->ref_count > 1)
- cl->func (key, fmt, cl->user_data);
-}
-
void
go_format_foreach (GHFunc func, gpointer user_data)
{
- if (style_format_hash != NULL) {
- _go_format_foreach_t cl = {func, user_data};
+ if (style_format_hash != NULL)
g_hash_table_foreach (style_format_hash,
- (GHFunc) go_format_refcount_cb, &cl);
- }
+ func, user_data);
}
/* used to generate formats when delocalizing so keep the leadings caps */
@@ -5131,8 +5116,15 @@ go_format_unref (GOFormat const *gf_)
G_GNUC_FUNCTION,
gf, gf->format, gf->ref_count);
#endif
- if (gf->ref_count != 0)
+ if (gf->ref_count > 1)
+ return;
+
+ if (gf->ref_count == 1) {
+ if (NULL != style_format_hash &&
+ gf_ == g_hash_table_lookup (style_format_hash, gf_->format))
+ g_hash_table_remove (style_format_hash, gf_->format);
return;
+ }
switch (gf->typ) {
case GO_FMT_COND: {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]