diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2007-10-02 19:54:42 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@src.gnome.org> | 2007-10-02 19:54:42 +0800 |
commit | 09d4af6fff63dd112b8bb42087f14f7018e2f78c (patch) | |
tree | 991537a9ea1d8487334f6fb299098daf425f9db8 /mail | |
parent | 79521efaeecfbaf717e465670fcd2724aea53578 (diff) | |
download | gsoc2013-evolution-09d4af6fff63dd112b8bb42087f14f7018e2f78c.tar gsoc2013-evolution-09d4af6fff63dd112b8bb42087f14f7018e2f78c.tar.gz gsoc2013-evolution-09d4af6fff63dd112b8bb42087f14f7018e2f78c.tar.bz2 gsoc2013-evolution-09d4af6fff63dd112b8bb42087f14f7018e2f78c.tar.lz gsoc2013-evolution-09d4af6fff63dd112b8bb42087f14f7018e2f78c.tar.xz gsoc2013-evolution-09d4af6fff63dd112b8bb42087f14f7018e2f78c.tar.zst gsoc2013-evolution-09d4af6fff63dd112b8bb42087f14f7018e2f78c.zip |
** Fixes bug #469657
2007-10-02 Matthew Barnes <mbarnes@redhat.com>
** 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
Diffstat (limited to 'mail')
-rw-r--r-- | mail/ChangeLog | 16 | ||||
-rw-r--r-- | mail/em-composer-prefs.c | 16 | ||||
-rw-r--r-- | mail/em-folder-tree-model.c | 73 | ||||
-rw-r--r-- | mail/em-format-html.c | 28 | ||||
-rw-r--r-- | mail/em-format.c | 14 | ||||
-rw-r--r-- | mail/em-migrate.c | 22 | ||||
-rw-r--r-- | mail/em-subscribe-editor.c | 21 | ||||
-rw-r--r-- | mail/importers/elm-importer.c | 22 | ||||
-rw-r--r-- | mail/mail-component.c | 25 | ||||
-rw-r--r-- | mail/mail-send-recv.c | 60 | ||||
-rw-r--r-- | mail/message-list.c | 30 |
11 files changed, 146 insertions, 181 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index d4c9202544..b27e61c57f 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,19 @@ +2007-10-02 Matthew Barnes <mbarnes@redhat.com> + + ** Fixes part of bug #469657 + + * em-composer-prefs.c: + * em-folder-tree-model.c: + * em-format.c: + * em-format-html.c: + * em-migrate.c: + * em-subscribe-editor.c: + * mail-component.c: + * mail-send-recv.c: + * message-list.c: + * importers/elm-importer.c: + Use destroy functions in GHashTables to simplify memory management. + 2007-10-01 Sankar P <psankar@novell.com> * em-format-html.c: (efh_format_headers): diff --git a/mail/em-composer-prefs.c b/mail/em-composer-prefs.c index 7805c8a61b..15944bad72 100644 --- a/mail/em-composer-prefs.c +++ b/mail/em-composer-prefs.c @@ -121,13 +121,10 @@ static void em_composer_prefs_init (EMComposerPrefs *prefs) { prefs->enabled_pixbuf = e_icon_factory_get_icon ("stock_mark", E_ICON_SIZE_MENU); - prefs->sig_hash = g_hash_table_new (g_direct_hash, g_direct_equal); -} - -static void -row_free (ESignature *sig, GtkTreeRowReference *row, gpointer user_data) -{ - gtk_tree_row_reference_free (row); + prefs->sig_hash = g_hash_table_new_full ( + g_direct_hash, g_direct_equal, + (GDestroyNotify) NULL, + (GDestroyNotify) gtk_tree_row_reference_free); } static void @@ -138,7 +135,6 @@ em_composer_prefs_finalise (GObject *obj) g_object_unref (prefs->gui); g_object_unref (prefs->enabled_pixbuf); - g_hash_table_foreach (prefs->sig_hash, (GHFunc) row_free, NULL); g_hash_table_destroy (prefs->sig_hash); G_OBJECT_CLASS (parent_class)->finalize (obj); @@ -241,11 +237,9 @@ signature_removed (ESignatureList *signatures, ESignature *sig, EMComposerPrefs if (!(row = g_hash_table_lookup (prefs->sig_hash, sig))) return; - g_hash_table_remove (prefs->sig_hash, sig); - model = gtk_tree_view_get_model (prefs->sig_list); path = gtk_tree_row_reference_get_path (row); - gtk_tree_row_reference_free (row); + g_hash_table_remove (prefs->sig_hash, sig); if (!gtk_tree_model_get_iter (model, &iter, path)) { gtk_tree_path_free (path); diff --git a/mail/em-folder-tree-model.c b/mail/em-folder-tree-model.c index 1e9294e869..68c90d6460 100644 --- a/mail/em-folder-tree-model.c +++ b/mail/em-folder-tree-model.c @@ -234,27 +234,6 @@ sort_cb (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer user_data } static void -em_folder_tree_model_init (EMFolderTreeModel *model) -{ - model->store_hash = g_hash_table_new (g_direct_hash, g_direct_equal); - model->uri_hash = g_hash_table_new (g_str_hash, g_str_equal); - - gtk_tree_sortable_set_default_sort_func ((GtkTreeSortable *) model, sort_cb, NULL, NULL); - - model->accounts = mail_config_get_accounts (); - model->account_hash = g_hash_table_new (g_direct_hash, g_direct_equal); - model->account_changed_id = g_signal_connect (model->accounts, "account-changed", G_CALLBACK (account_changed), model); - model->account_removed_id = g_signal_connect (model->accounts, "account-removed", G_CALLBACK (account_removed), model); -} - -static void -full_hash_free (gpointer key, gpointer value, gpointer user_data) -{ - g_free (key); - gtk_tree_row_reference_free (value); -} - -static void store_info_free (struct _EMFolderTreeModelStoreInfo *si) { camel_object_remove_event (si->store, si->created_id); @@ -266,23 +245,29 @@ store_info_free (struct _EMFolderTreeModelStoreInfo *si) g_free (si->display_name); camel_object_unref (si->store); gtk_tree_row_reference_free (si->row); - g_hash_table_foreach (si->full_hash, full_hash_free, NULL); + g_hash_table_destroy (si->full_hash); g_free (si); } static void -store_hash_free (gpointer key, gpointer value, gpointer user_data) +em_folder_tree_model_init (EMFolderTreeModel *model) { - struct _EMFolderTreeModelStoreInfo *si = value; - - store_info_free (si); -} + model->store_hash = g_hash_table_new_full ( + g_direct_hash, g_direct_equal, + (GDestroyNotify) NULL, + (GDestroyNotify) store_info_free); -static void -uri_hash_free (gpointer key, gpointer value, gpointer user_data) -{ - g_free (key); - gtk_tree_row_reference_free (value); + model->uri_hash = g_hash_table_new_full ( + g_str_hash, g_str_equal, + (GDestroyNotify) g_free, + (GDestroyNotify) gtk_tree_row_reference_free); + + gtk_tree_sortable_set_default_sort_func ((GtkTreeSortable *) model, sort_cb, NULL, NULL); + + model->accounts = mail_config_get_accounts (); + model->account_hash = g_hash_table_new (g_direct_hash, g_direct_equal); + model->account_changed_id = g_signal_connect (model->accounts, "account-changed", G_CALLBACK (account_changed), model); + model->account_removed_id = g_signal_connect (model->accounts, "account-removed", G_CALLBACK (account_removed), model); } static void @@ -294,10 +279,7 @@ em_folder_tree_model_finalize (GObject *obj) if (model->state) xmlFreeDoc (model->state); - g_hash_table_foreach (model->store_hash, store_hash_free, NULL); g_hash_table_destroy (model->store_hash); - - g_hash_table_foreach (model->uri_hash, uri_hash_free, NULL); g_hash_table_destroy (model->uri_hash); g_hash_table_destroy (model->account_hash); @@ -807,7 +789,10 @@ em_folder_tree_model_add_store (EMFolderTreeModel *model, CamelStore *store, con si->store = store; si->account = account; si->row = row; - si->full_hash = g_hash_table_new (g_str_hash, g_str_equal); + si->full_hash = g_hash_table_new_full ( + g_str_hash, g_str_equal, + (GDestroyNotify) g_free, + (GDestroyNotify) gtk_tree_row_reference_free); g_hash_table_insert (model->store_hash, store, si); g_hash_table_insert (model->account_hash, account, si); @@ -842,15 +827,10 @@ em_folder_tree_model_add_store (EMFolderTreeModel *model, CamelStore *store, con static void em_folder_tree_model_remove_uri (EMFolderTreeModel *model, const char *uri) { - GtkTreeRowReference *row; - g_return_if_fail (EM_IS_FOLDER_TREE_MODEL (model)); g_return_if_fail (uri != NULL); - - if ((row = g_hash_table_lookup (model->uri_hash, uri))) { - g_hash_table_remove (model->uri_hash, uri); - gtk_tree_row_reference_free (row); - } + + g_hash_table_remove (model->uri_hash, uri); } @@ -874,7 +854,6 @@ em_folder_tree_model_remove_store_info (EMFolderTreeModel *model, CamelStore *st void em_folder_tree_model_remove_folders (EMFolderTreeModel *model, struct _EMFolderTreeModelStoreInfo *si, GtkTreeIter *toplevel) { - GtkTreeRowReference *row; char *uri, *full_name; gboolean is_store, go; GtkTreeIter iter; @@ -892,11 +871,9 @@ em_folder_tree_model_remove_folders (EMFolderTreeModel *model, struct _EMFolderT gtk_tree_model_get ((GtkTreeModel *) model, toplevel, COL_STRING_URI, &uri, COL_STRING_FULL_NAME, &full_name, COL_BOOL_IS_STORE, &is_store, -1); - - if (full_name && (row = g_hash_table_lookup (si->full_hash, full_name))) { + + if (full_name) g_hash_table_remove (si->full_hash, full_name); - gtk_tree_row_reference_free (row); - } if (uri) em_folder_tree_model_remove_uri (model, uri); 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 @@ -127,6 +127,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) { EMFormatHTML *efh = (EMFormatHTML *)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); @@ -193,16 +204,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) { EMFormatHTML *efh = (EMFormatHTML *)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; } diff --git a/mail/em-format.c b/mail/em-format.c index f22cc1a577..ce820cab11 100644 --- a/mail/em-format.c +++ b/mail/em-format.c @@ -91,10 +91,8 @@ static guint emf_signals[EMF_LAST_SIGNAL]; static GObjectClass *emf_parent; static void -emf_free_cache(void *key, void *val, void *dat) +emf_free_cache(struct _EMFormatCache *efc) { - struct _EMFormatCache *efc = val; - if (efc->valid) camel_cipher_validity_free(efc->valid); if (efc->secured) @@ -119,7 +117,10 @@ emf_init(GObject *o) { EMFormat *emf = (EMFormat *)o; - emf->inline_table = g_hash_table_new(g_str_hash, g_str_equal); + emf->inline_table = g_hash_table_new_full ( + g_str_hash, g_str_equal, + (GDestroyNotify) NULL, + (GDestroyNotify) emf_free_cache); emf->composer = FALSE; emf->show_photo = TRUE; emf->photo_local = TRUE; @@ -136,7 +137,6 @@ emf_finalise(GObject *o) if (emf->session) camel_object_unref(emf->session); - g_hash_table_foreach(emf->inline_table, emf_free_cache, NULL); g_hash_table_destroy(emf->inline_table); em_format_clear_headers(emf); @@ -642,9 +642,7 @@ emf_format_clone(EMFormat *emf, CamelFolder *folder, const char *uid, CamelMimeM em_format_clear_puri_tree(emf); if (emf != emfsource) { - g_hash_table_foreach(emf->inline_table, emf_free_cache, NULL); - g_hash_table_destroy(emf->inline_table); - emf->inline_table = g_hash_table_new(g_str_hash, g_str_equal); + g_hash_table_remove_all(emf->inline_table); if (emfsource) { struct _EMFormatHeader *h; diff --git a/mail/em-migrate.c b/mail/em-migrate.c index 2fc53ebf5f..4e8f3e3c61 100644 --- a/mail/em-migrate.c +++ b/mail/em-migrate.c @@ -233,10 +233,8 @@ static GHashTable *accounts_1_0 = NULL; static GHashTable *accounts_name_1_0 = NULL; static void -imap_folder_info_1_0_free(gpointer key, gpointer value, gpointer user_data) +imap_folder_info_1_0_free (struct _imap_folder_info_1_0 *fi) { - struct _imap_folder_info_1_0 *fi = value; - g_free(fi->folder); g_free(fi); } @@ -249,17 +247,10 @@ account_info_1_0_free (struct _account_info_1_0 *ai) g_free(ai->base_uri); g_free(ai->u.imap.namespace); g_free(ai->u.imap.namespace_full); - g_hash_table_foreach(ai->u.imap.folders, (GHFunc) imap_folder_info_1_0_free, NULL); g_hash_table_destroy(ai->u.imap.folders); g_free(ai); } -static void -accounts_1_0_free(gpointer key, gpointer value, gpointer user_data) -{ - account_info_1_0_free(value); -} - static char * get_base_uri(const char *val) { @@ -394,7 +385,10 @@ read_imap_storeinfo (struct _account_info_1_0 *si) char *buf, *folder, dir_sep, *path, *name, *p; struct _imap_folder_info_1_0 *fi; - si->u.imap.folders = g_hash_table_new (g_str_hash, g_str_equal); + si->u.imap.folders = g_hash_table_new_full ( + g_str_hash, g_str_equal, + (GDestroyNotify) NULL, + (GDestroyNotify) imap_folder_info_1_0_free); /* get details from uri first */ name = strstr (si->uri, ";override_namespace"); @@ -545,14 +539,16 @@ load_accounts_1_0 (xmlDocPtr doc) static int em_migrate_1_0 (const char *evolution_dir, xmlDocPtr config_xmldb, xmlDocPtr filters, xmlDocPtr vfolders, CamelException *ex) { - accounts_1_0 = g_hash_table_new (g_str_hash, g_str_equal); + accounts_1_0 = g_hash_table_new_full ( + g_str_hash, g_str_equal, + (GDestroyNotify) NULL, + (GDestroyNotify) account_info_1_0_free); accounts_name_1_0 = g_hash_table_new (g_str_hash, g_str_equal); load_accounts_1_0 (config_xmldb); upgrade_xml_uris(filters, upgrade_xml_uris_1_0); upgrade_xml_uris(vfolders, upgrade_xml_uris_1_0); - g_hash_table_foreach (accounts_1_0, (GHFunc) accounts_1_0_free, NULL); g_hash_table_destroy (accounts_1_0); g_hash_table_destroy (accounts_name_1_0); diff --git a/mail/em-subscribe-editor.c b/mail/em-subscribe-editor.c index 5945f6d1ad..53f3e0fdca 100644 --- a/mail/em-subscribe-editor.c +++ b/mail/em-subscribe-editor.c @@ -129,7 +129,7 @@ static int sub_queue_fill_level(EMSubscribe *sub, EMSubscribeNode *node); static void sub_selection_changed(GtkTreeSelection *selection, EMSubscribe *sub); static void -sub_node_free(char *key, EMSubscribeNode *node, EMSubscribe *sub) +sub_node_free(EMSubscribeNode *node) { d(printf("sub node free '%s'\n", node->info?node->info->full_name:"<unknown>")); if (node->path) @@ -153,10 +153,8 @@ sub_unref(EMSubscribe *sub) d(printf("subscribe object finalised\n")); /* we dont have to delete the "subscribe" task list, as it must be empty, otherwise we wouldn't be unreffed (intentional circular reference) */ - if (sub->folders) { - g_hash_table_foreach(sub->folders, (GHFunc)sub_node_free, sub); + if (sub->folders) g_hash_table_destroy(sub->folders); - } l = sub->info_list; while (l) { GSList *n = l->next; @@ -615,7 +613,10 @@ subscribe_set_store(EMSubscribe *sub, CamelStore *store) sub->store = store; camel_object_ref(store); - sub->folders = g_hash_table_new(g_str_hash, g_str_equal); + sub->folders = g_hash_table_new_full ( + g_str_hash, g_str_equal, + (GDestroyNotify) NULL, + (GDestroyNotify) sub_node_free); model = gtk_tree_store_new (3, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_POINTER); sub->tree = (GtkTreeView *) gtk_tree_view_new_with_model ((GtkTreeModel *) model); @@ -692,11 +693,13 @@ sub_editor_refresh(GtkWidget *w, EMSubscribeEditor *se) gtk_tree_store_clear((GtkTreeStore *)gtk_tree_view_get_model(sub->tree)); e_dlist_init(&sub->pending); - if (sub->folders) { - g_hash_table_foreach(sub->folders, (GHFunc)sub_node_free, sub); + + if (sub->folders) g_hash_table_destroy(sub->folders); - } - sub->folders = g_hash_table_new(g_str_hash, g_str_equal); + sub->folders = g_hash_table_new_full ( + g_str_hash, g_str_equal, + (GDestroyNotify) NULL, + (GDestroyNotify) sub_node_free); l = sub->info_list; sub->info_list = NULL; diff --git a/mail/importers/elm-importer.c b/mail/importers/elm-importer.c index 1204c0d09e..ca4b18bdf5 100644 --- a/mail/importers/elm-importer.c +++ b/mail/importers/elm-importer.c @@ -68,7 +68,12 @@ parse_elm_rc(const char *elmrc) { char line[4096]; FILE *handle; - GHashTable *prefs = g_hash_table_new(g_str_hash, g_str_equal); + GHashTable *prefs; + + prefs = g_hash_table_new_full ( + g_str_hash, g_str_equal, + (GDestroyNotify) g_free, + (GDestroyNotify) g_free); if (!g_file_test(elmrc, G_FILE_TEST_IS_REGULAR)) return prefs; @@ -119,19 +124,6 @@ parse_elm_rc(const char *elmrc) return prefs; } -static void -elm_free_rc_item(void *k, void *v, void *d) -{ - g_free(k); - g_free(v); -} - -static void -elm_free_rc(void *prefs) -{ - g_hash_table_foreach(prefs, elm_free_rc_item, NULL); -} - static char * elm_get_rc(EImport *ei, const char *name) { @@ -143,7 +135,7 @@ elm_get_rc(EImport *ei, const char *name) elmrc = g_build_filename(g_get_home_dir(), ".elm/elmrc", NULL); prefs = parse_elm_rc(elmrc); g_free(elmrc); - g_object_set_data_full((GObject *)ei, "elm-rc", prefs, elm_free_rc); + g_object_set_data((GObject *)ei, "elm-rc", prefs); } if (prefs == NULL) diff --git a/mail/mail-component.c b/mail/mail-component.c index c27fee6250..2aa9274b30 100644 --- a/mail/mail-component.c +++ b/mail/mail-component.c @@ -460,13 +460,6 @@ impl_dispose (GObject *object) } static void -store_hash_free (CamelStore *store, struct _store_info *si, void *data) -{ - si->removed = 1; - store_info_unref(si); -} - -static void impl_finalize (GObject *object) { MailComponentPrivate *priv = MAIL_COMPONENT (object)->priv; @@ -475,7 +468,6 @@ impl_finalize (GObject *object) mail_async_event_destroy (priv->async_event); - g_hash_table_foreach (priv->store_hash, (GHFunc)store_hash_free, NULL); g_hash_table_destroy (priv->store_hash); if (mail_async_event_destroy (priv->async_event) == -1) { @@ -1172,6 +1164,13 @@ mail_component_class_init (MailComponentClass *class) } static void +store_hash_free (struct _store_info *si) +{ + si->removed = 1; + store_info_unref(si); +} + +static void mail_component_init (MailComponent *component) { MailComponentPrivate *priv; @@ -1200,7 +1199,10 @@ mail_component_init (MailComponent *component) mail_session_init (priv->base_directory); priv->async_event = mail_async_event_new(); - priv->store_hash = g_hash_table_new (NULL, NULL); + priv->store_hash = g_hash_table_new_full ( + NULL, NULL, + (GDestroyNotify) NULL, + (GDestroyNotify) store_hash_free); mail_autoreceive_init(); } @@ -1319,7 +1321,6 @@ void mail_component_remove_store (MailComponent *component, CamelStore *store) { MailComponentPrivate *priv; - struct _store_info *si; MAIL_COMPONENT_DEFAULT(component); @@ -1331,13 +1332,11 @@ mail_component_remove_store (MailComponent *component, CamelStore *store) * URL will always return the same object. So this works. */ - if (!(si = g_hash_table_lookup (priv->store_hash, store))) + if (g_hash_table_lookup (priv->store_hash, store) == NULL) return; camel_object_ref (store); g_hash_table_remove (priv->store_hash, store); - si->removed = 1; - store_info_unref(si); /* so i guess potentially we could have a race, add a store while one being removed. ?? */ diff --git a/mail/mail-send-recv.c b/mail/mail-send-recv.c index f55415323f..ff6d3d6403 100644 --- a/mail/mail-send-recv.c +++ b/mail/mail-send-recv.c @@ -134,6 +134,27 @@ static CamelFolder *receive_get_folder(CamelFilterDriver *d, const char *uri, vo static struct _send_data *send_data = NULL; static GtkWidget *send_recv_dialog = NULL; +static void +free_folder_info(struct _folder_info *info) +{ + /*camel_folder_thaw (info->folder); */ + mail_sync_folder(info->folder, NULL, NULL); + camel_object_unref(info->folder); + g_free(info->uri); + g_free(info); +} + +static void +free_send_info(struct _send_info *info) +{ + g_free(info->uri); + camel_operation_unref(info->cancel); + if (info->timeout_id != 0) + g_source_remove(info->timeout_id); + g_free(info->what); + g_free(info); +} + static struct _send_data * setup_send_data(void) { @@ -142,10 +163,16 @@ setup_send_data(void) if (send_data == NULL) { send_data = data = g_malloc0(sizeof(*data)); data->lock = g_mutex_new(); - data->folders = g_hash_table_new(g_str_hash, g_str_equal); + data->folders = g_hash_table_new_full ( + g_str_hash, g_str_equal, + (GDestroyNotify) NULL, + (GDestroyNotify) free_folder_info); data->inbox = mail_component_get_folder(NULL, MAIL_COMPONENT_FOLDER_LOCAL_INBOX); camel_object_ref(data->inbox); - data->active = g_hash_table_new(g_str_hash, g_str_equal); + data->active = g_hash_table_new_full ( + g_str_hash, g_str_equal, + (GDestroyNotify) NULL, + (GDestroyNotify) free_send_info); } return send_data; } @@ -166,27 +193,6 @@ receive_cancel(GtkButton *button, struct _send_info *info) } static void -free_folder_info(void *key, struct _folder_info *info, void *data) -{ - /*camel_folder_thaw (info->folder); */ - mail_sync_folder(info->folder, NULL, NULL); - camel_object_unref(info->folder); - g_free(info->uri); - g_free(info); -} - -static void -free_send_info(void *key, struct _send_info *info, void *data) -{ - g_free(info->uri); - camel_operation_unref(info->cancel); - if (info->timeout_id != 0) - g_source_remove(info->timeout_id); - g_free(info->what); - g_free(info); -} - -static void free_send_data(void) { struct _send_data *data = send_data; @@ -200,9 +206,7 @@ free_send_data(void) } g_list_free(data->infos); - g_hash_table_foreach(data->active, (GHFunc)free_send_info, NULL); g_hash_table_destroy(data->active); - g_hash_table_foreach(data->folders, (GHFunc)free_folder_info, NULL); g_hash_table_destroy(data->folders); g_mutex_free(data->lock); g_free(data); @@ -708,9 +712,9 @@ receive_done (char *uri, void *data) /* remove/free this active download */ d(printf("%s: freeing info %p\n", G_GNUC_FUNCTION, info)); if (info->type == SEND_SEND) - g_hash_table_remove(info->data->active, SEND_URI_KEY); + g_hash_table_steal(info->data->active, SEND_URI_KEY); else - g_hash_table_remove(info->data->active, info->uri); + g_hash_table_steal(info->data->active, info->uri); info->data->infos = g_list_remove(info->data->infos, info); if (g_hash_table_size(info->data->active) == 0) { @@ -719,7 +723,7 @@ receive_done (char *uri, void *data) free_send_data(); } - free_send_info(NULL, info, NULL); + free_send_info(info); } /* although we dont do anythign smart here yet, there is no need for this interface to diff --git a/mail/message-list.c b/mail/message-list.c index d359bb40d4..bc21e17bae 100644 --- a/mail/message-list.c +++ b/mail/message-list.c @@ -2065,7 +2065,10 @@ message_list_init (MessageList *message_list) gtk_scrolled_window_set_vadjustment ((GtkScrolledWindow *) message_list, adjustment); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (message_list), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); - message_list->normalised_hash = g_hash_table_new (g_str_hash, g_str_equal); + message_list->normalised_hash = g_hash_table_new_full ( + g_str_hash, g_str_equal, + (GDestroyNotify) NULL, + (GDestroyNotify) e_poolv_destroy); message_list->hidden = NULL; message_list->hidden_pool = NULL; @@ -2096,14 +2099,6 @@ message_list_init (MessageList *message_list) g_signal_connect (((GtkScrolledWindow *) message_list)->vscrollbar, "value-changed", G_CALLBACK (ml_scrolled), message_list); } -static gboolean -normalised_free (gpointer key, gpointer value, gpointer user_data) -{ - e_poolv_destroy (value); - - return TRUE; -} - static void message_list_destroy(GtkObject *object) { @@ -2169,7 +2164,6 @@ message_list_finalise (GObject *object) MessageList *message_list = MESSAGE_LIST (object); struct _MessageListPrivate *p = message_list->priv; - g_hash_table_foreach (message_list->normalised_hash, (GHFunc) normalised_free, NULL); g_hash_table_destroy (message_list->normalised_hash); if (message_list->thread_tree) @@ -3044,16 +3038,10 @@ main_folder_changed (CamelObject *o, gpointer event_data, gpointer user_data) d(printf("changed = %d added = %d removed = %d\n", changes->uid_changed->len, changes->uid_added->len, changes->uid_removed->len)); - for (i = 0; i < changes->uid_removed->len; i++) { - /* uncache the normalised strings for these uids */ - EPoolv *poolv; - - poolv = g_hash_table_lookup (ml->normalised_hash, changes->uid_removed->pdata[i]); - if (poolv != NULL) { - g_hash_table_remove (ml->normalised_hash, changes->uid_removed->pdata[i]); - e_poolv_destroy (poolv); - } - } + for (i = 0; i < changes->uid_removed->len; i++) + g_hash_table_remove ( + ml->normalised_hash, + changes->uid_removed->pdata[i]); /* check if the hidden state has changed, if so modify accordingly, then regenerate */ if (ml->hidejunk || ml->hidedeleted) @@ -3132,7 +3120,7 @@ message_list_set_folder (MessageList *message_list, CamelFolder *folder, const c } /* reset the normalised sort performance hack */ - g_hash_table_foreach_remove (message_list->normalised_hash, normalised_free, NULL); + g_hash_table_remove_all (message_list->normalised_hash); mail_regen_cancel(message_list); |