From 09d4af6fff63dd112b8bb42087f14f7018e2f78c Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 2 Oct 2007 11:54:42 +0000 Subject: ** Fixes bug #469657 2007-10-02 Matthew Barnes ** Fixes bug #469657 * addressbook/importers/evolution-ldif-importer.c: * calendar/gui/comp-editor-factory.c: * composer/e-msg-composer.c: * e-util/e-config-listener.c: * mail/em-composer-prefs.c: * mail/em-folder-tree-model.c: * mail/em-format.c: * mail/em-format-html.c: * mail/em-migrate.c: * mail/em-subscribe-editor.c: * mail/mail-component.c: * mail/mail-send-recv.c: * mail/message-list.c: * mail/importers/elm-importer.c: * plugins/exchange-operations/exchange-folder-size-display.c: * plugins/mono/mono-plugin.c: * shell/e-shell-settings-dialog.c: * tools/killev.c: * widgets/table/e-table-extras.c: * widgets/table/e-table-selection-model.c: Use destroy functions in GHashTables to simplify memory management. svn path=/trunk/; revision=34344 --- mail/em-format-html.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'mail/em-format-html.c') diff --git a/mail/em-format-html.c b/mail/em-format-html.c index b1961bd2b2..6953992f5a 100644 --- a/mail/em-format-html.c +++ b/mail/em-format-html.c @@ -126,6 +126,14 @@ static CamelDataCache *emfh_http_cache; #define EMFH_HTTP_CACHE_PATH "http" +static void +efh_free_cache(struct _EMFormatHTMLCache *efhc) +{ + if (efhc->textmp) + camel_object_unref(efhc->textmp); + g_free(efhc); +} + static void efh_init(GObject *o) { @@ -137,7 +145,10 @@ efh_init(GObject *o) e_dlist_init(&efh->priv->pending_jobs); efh->priv->lock = g_mutex_new(); efh->priv->format_id = -1; - efh->priv->text_inline_parts = g_hash_table_new(g_str_hash, g_str_equal); + efh->priv->text_inline_parts = g_hash_table_new_full ( + g_str_hash, g_str_equal, + (GDestroyNotify) NULL, + (GDestroyNotify) efh_free_cache); efh->html = (GtkHTML *)gtk_html_new(); gtk_html_set_blocking(efh->html, FALSE); @@ -192,16 +203,6 @@ efh_insert_cache(EMFormatHTML *efh, const char *partid) } -static void -efh_free_cache(void *key, void *val, void *dat) -{ - struct _EMFormatHTMLCache *efhc = val; - - if (efhc->textmp) - camel_object_unref(efhc->textmp); - g_free(efhc); -} - static void efh_finalise(GObject *o) { @@ -213,7 +214,6 @@ efh_finalise(GObject *o) efh_gtkhtml_destroy(efh->html, efh); - g_hash_table_foreach(efh->priv->text_inline_parts, efh_free_cache, NULL); g_hash_table_destroy(efh->priv->text_inline_parts); g_free(efh->priv); @@ -1397,9 +1397,7 @@ efh_format_timeout(struct _format_msg *m) | GTK_HTML_BEGIN_BLOCK_UPDATES | GTK_HTML_BEGIN_BLOCK_IMAGES); } else { /* clear cache of inline-scanned text parts */ - g_hash_table_foreach(p->text_inline_parts, efh_free_cache, NULL); - g_hash_table_destroy(p->text_inline_parts); - p->text_inline_parts = g_hash_table_new(g_str_hash, g_str_equal); + g_hash_table_remove_all(p->text_inline_parts); p->last_part = m->message; } -- cgit v1.2.3