From 044fde0583993fae3ec3c511ac0a5058c5745302 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Fri, 13 Apr 2001 21:36:09 +0000 Subject: Plug leaks. * camel-object.c (camel_object_hook_event): * camel-uid-cache.c (camel_uid_cache_get_new_uids): * camel-url.c (camel_url_new_with_base): Plug leaks. * camel-remote-store.c (camel_remote_store_init): Don't re-initialize the folders hash table. * providers/imap/camel-imap-store.c (imap_disconnect): Free authtypes since they'll be re-read on re-connect. (get_folder_info): Free folderinfos that we're discarding from the list. svn path=/trunk/; revision=9302 --- camel/ChangeLog | 14 ++++++++++++++ camel/camel-object.c | 15 +++++++++++---- camel/camel-remote-store.c | 3 --- camel/camel-uid-cache.c | 7 +++++-- camel/camel-url.c | 1 + camel/providers/imap/camel-imap-store.c | 11 ++++++++++- 6 files changed, 41 insertions(+), 10 deletions(-) diff --git a/camel/ChangeLog b/camel/ChangeLog index 506a7cadaa..7b2d2fa8d3 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,17 @@ +2001-04-13 Dan Winship + + * camel-object.c (camel_object_hook_event): + * camel-uid-cache.c (camel_uid_cache_get_new_uids): + * camel-url.c (camel_url_new_with_base): Plug leaks. + + * camel-remote-store.c (camel_remote_store_init): Don't + re-initialize the folders hash table. + + * providers/imap/camel-imap-store.c (imap_disconnect): Free + authtypes since they'll be re-read on re-connect. + (get_folder_info): Free folderinfos that we're discarding from the + list. + 2001-04-12 Jeffrey Stedfast * camel-pgp-context.c (camel_pgp_context_get_type): Oops, lets not diff --git a/camel/camel-object.c b/camel/camel-object.c index 53e7069653..bdb17fa177 100644 --- a/camel/camel-object.c +++ b/camel/camel-object.c @@ -690,6 +690,7 @@ camel_object_hook_event (CamelObject * obj, const gchar * name, { GSList *hooklist; CamelHookPair *pair; + gpointer old_name, old_hooklist; g_return_if_fail (CAMEL_IS_OBJECT (obj)); g_return_if_fail (name); @@ -703,10 +704,16 @@ camel_object_hook_event (CamelObject * obj, const gchar * name, pair->func = hook; pair->user_data = user_data; - hooklist = g_hash_table_lookup (obj->event_to_hooklist, name); - hooklist = g_slist_prepend (hooklist, pair); - g_hash_table_insert (obj->event_to_hooklist, g_strdup (name), - hooklist); + if (g_hash_table_lookup_extended (obj->event_to_hooklist, name, + &old_name, &old_hooklist)) { + hooklist = g_slist_prepend (old_hooklist, pair); + g_hash_table_insert (obj->event_to_hooklist, old_name, + hooklist); + } else { + hooklist = g_slist_prepend (NULL, pair); + g_hash_table_insert (obj->event_to_hooklist, g_strdup (name), + hooklist); + } } void diff --git a/camel/camel-remote-store.c b/camel/camel-remote-store.c index 21bd252c45..a0f142e889 100644 --- a/camel/camel-remote-store.c +++ b/camel/camel-remote-store.c @@ -106,11 +106,8 @@ camel_remote_store_class_init (CamelRemoteStoreClass *camel_remote_store_class) static void camel_remote_store_init (CamelObject *object) { - CamelStore *store = CAMEL_STORE (object); CamelRemoteStore *remote_store = CAMEL_REMOTE_STORE (object); - store->folders = g_hash_table_new (g_str_hash, g_str_equal); - remote_store->istream = NULL; remote_store->ostream = NULL; remote_store->timeout_id = 0; diff --git a/camel/camel-uid-cache.c b/camel/camel-uid-cache.c index 0997e9a6a7..fcea86f608 100644 --- a/camel/camel-uid-cache.c +++ b/camel/camel-uid-cache.c @@ -153,6 +153,7 @@ GPtrArray * camel_uid_cache_get_new_uids (CamelUIDCache *cache, GPtrArray *uids) { GPtrArray *new_uids; + gpointer old_uid, old_level; char *uid; int i; @@ -161,9 +162,11 @@ camel_uid_cache_get_new_uids (CamelUIDCache *cache, GPtrArray *uids) for (i = 0; i < uids->len; i++) { uid = uids->pdata[i]; - if (g_hash_table_lookup (cache->uids, uid)) + if (g_hash_table_lookup_extended (cache->uids, uid, + &old_uid, &old_level)) { g_hash_table_remove (cache->uids, uid); - else + g_free (old_uid); + } else g_ptr_array_add (new_uids, g_strdup (uid)); g_hash_table_insert (cache->uids, g_strdup (uid), GINT_TO_POINTER (cache->level)); diff --git a/camel/camel-url.c b/camel/camel-url.c index e52206137e..aa4c0e2c4f 100644 --- a/camel/camel-url.c +++ b/camel/camel-url.c @@ -169,6 +169,7 @@ camel_url_new_with_base (CamelURL *base, const char *url_string) camel_url_decode (name); g_datalist_set_data_full (&url->params, name, value, g_free); + g_free (name); } } end = semi; diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c index 21211616ae..7ff46b9850 100644 --- a/camel/providers/imap/camel-imap-store.c +++ b/camel/providers/imap/camel-imap-store.c @@ -734,6 +734,13 @@ imap_disconnect (CamelService *service, gboolean clean, CamelException *ex) store->subscribed_folders = NULL; } + if (imap_store->authtypes) { + g_hash_table_foreach_remove (imap_store->authtypes, + free_key, NULL); + g_hash_table_destroy (imap_store->authtypes); + imap_store->authtypes = NULL; + } + if (store->namespace && !(store->parameters & IMAP_PARAM_OVERRIDE_NAMESPACE)) { g_free (store->namespace); store->namespace = NULL; @@ -1148,8 +1155,10 @@ get_folder_info (CamelStore *store, const char *top, gboolean fast, return NULL; if (folders->len) { fi = folders->pdata[0]; - if (!fi->url) + if (!fi->url) { + camel_folder_info_free (fi); g_ptr_array_remove_index (folders, 0); + } } /* If we want to look at only subscribed folders AND -- cgit v1.2.3