aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2007-10-02 19:54:42 +0800
committerMatthew Barnes <mbarnes@src.gnome.org>2007-10-02 19:54:42 +0800
commit09d4af6fff63dd112b8bb42087f14f7018e2f78c (patch)
tree991537a9ea1d8487334f6fb299098daf425f9db8
parent79521efaeecfbaf717e465670fcd2724aea53578 (diff)
downloadgsoc2013-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
-rw-r--r--ChangeLog7
-rw-r--r--addressbook/ChangeLog7
-rw-r--r--addressbook/importers/evolution-ldif-importer.c12
-rw-r--r--calendar/ChangeLog7
-rw-r--r--calendar/gui/comp-editor-factory.c30
-rw-r--r--composer/ChangeLog7
-rw-r--r--composer/e-msg-composer.c77
-rw-r--r--e-util/ChangeLog7
-rw-r--r--e-util/e-config-listener.c71
-rw-r--r--mail/ChangeLog16
-rw-r--r--mail/em-composer-prefs.c16
-rw-r--r--mail/em-folder-tree-model.c73
-rw-r--r--mail/em-format-html.c28
-rw-r--r--mail/em-format.c14
-rw-r--r--mail/em-migrate.c22
-rw-r--r--mail/em-subscribe-editor.c21
-rw-r--r--mail/importers/elm-importer.c22
-rw-r--r--mail/mail-component.c25
-rw-r--r--mail/mail-send-recv.c60
-rw-r--r--mail/message-list.c30
-rw-r--r--plugins/exchange-operations/ChangeLog7
-rw-r--r--plugins/exchange-operations/exchange-folder-size-display.c18
-rw-r--r--plugins/mono/ChangeLog7
-rw-r--r--plugins/mono/mono-plugin.c6
-rw-r--r--shell/ChangeLog7
-rw-r--r--shell/e-shell-settings-dialog.c14
-rw-r--r--tools/killev.c18
-rw-r--r--widgets/table/ChangeLog8
-rw-r--r--widgets/table/e-table-extras.c89
-rw-r--r--widgets/table/e-table-selection-model.c12
30 files changed, 343 insertions, 395 deletions
diff --git a/ChangeLog b/ChangeLog
index 7fbe5d2f5d..539949ec2c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2007-10-02 Matthew Barnes <mbarnes@redhat.com>
+
+ ** Fixes part of bug #469657
+
+ * tools/killev.c:
+ Use destroy functions in GHashTables to simplify memory management.
+
2007-09-27 Matthew Barnes <mbarnes@redhat.com>
** Fixes part of bug #477045
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index e7342e4e02..7f6ca320ad 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,10 @@
+2007-10-02 Matthew Barnes <mbarnes@redhat.com>
+
+ ** Fixes part of bug #469657
+
+ * importers/evolution-ldif-importer.c:
+ Use destroy functions in GHashTables to simplify memory management.
+
2007-10-01 Milan Crha <mcrha@redhat.com>
** Fix for bug #337539
diff --git a/addressbook/importers/evolution-ldif-importer.c b/addressbook/importers/evolution-ldif-importer.c
index 5080557c17..1e055db4da 100644
--- a/addressbook/importers/evolution-ldif-importer.c
+++ b/addressbook/importers/evolution-ldif-importer.c
@@ -576,12 +576,6 @@ ldif_supported(EImport *ei, EImportTarget *target, EImportImporter *im)
}
static void
-free_dn_hash(void *k, void *v, void *d)
-{
- g_free(k);
-}
-
-static void
ldif_import_done(LDIFImporter *gci)
{
if (gci->idle_id)
@@ -593,7 +587,6 @@ ldif_import_done(LDIFImporter *gci)
g_slist_foreach(gci->list_contacts, (GFunc) g_object_unref, NULL);
g_slist_free(gci->contacts);
g_slist_free(gci->list_contacts);
- g_hash_table_foreach(gci->dn_contact_hash, free_dn_hash, NULL);
g_hash_table_destroy(gci->dn_contact_hash);
e_import_complete(gci->import, gci->target);
@@ -639,7 +632,10 @@ ldif_import(EImport *ei, EImportTarget *target, EImportImporter *im)
fseek(file, 0, SEEK_END);
gci->size = ftell(file);
fseek(file, 0, SEEK_SET);
- gci->dn_contact_hash = g_hash_table_new(g_str_hash, g_str_equal);
+ gci->dn_contact_hash = g_hash_table_new_full (
+ g_str_hash, g_str_equal,
+ (GDestroyNotify) g_free,
+ (GDestroyNotify) NULL);
e_book_open(gci->book, FALSE, NULL);
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 44954fc8e0..df79689212 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,10 @@
+2007-10-02 Matthew Barnes <mbarnes@redhat.com>
+
+ ** Fixes part of bug #469657
+
+ * gui/comp-editor-factory.c:
+ Use destroy functions in GHashTables to simplify memory management.
+
2007-10-01 Milan Crha <mcrha@redhat.com>
** Fix for bug #428402
diff --git a/calendar/gui/comp-editor-factory.c b/calendar/gui/comp-editor-factory.c
index 95216604c8..dd508987d4 100644
--- a/calendar/gui/comp-editor-factory.c
+++ b/calendar/gui/comp-editor-factory.c
@@ -129,18 +129,6 @@ comp_editor_factory_class_init (CompEditorFactoryClass *class)
object_class->finalize = comp_editor_factory_finalize;
}
-/* Object initialization function for the component editor factory */
-static void
-comp_editor_factory_init (CompEditorFactory *factory)
-{
- CompEditorFactoryPrivate *priv;
-
- priv = g_new (CompEditorFactoryPrivate, 1);
- factory->priv = priv;
-
- priv->uri_client_hash = g_hash_table_new (g_str_hash, g_str_equal);
-}
-
/* Frees a Request structure */
static void
free_request (Request *r)
@@ -175,14 +163,19 @@ free_client (OpenClient *oc)
g_free (oc);
}
-/* Used from g_hash_table_foreach(); frees a client structure */
+/* Object initialization function for the component editor factory */
static void
-free_client_cb (gpointer key, gpointer value, gpointer data)
+comp_editor_factory_init (CompEditorFactory *factory)
{
- OpenClient *oc;
+ CompEditorFactoryPrivate *priv;
+
+ priv = g_new (CompEditorFactoryPrivate, 1);
+ factory->priv = priv;
- oc = value;
- free_client (oc);
+ priv->uri_client_hash = g_hash_table_new_full (
+ g_str_hash, g_str_equal,
+ (GDestroyNotify) NULL,
+ (GDestroyNotify) free_client);
}
/* Destroy handler for the component editor factory */
@@ -198,7 +191,6 @@ comp_editor_factory_finalize (GObject *object)
factory = COMP_EDITOR_FACTORY (object);
priv = factory->priv;
- g_hash_table_foreach (priv->uri_client_hash, free_client_cb, NULL);
g_hash_table_destroy (priv->uri_client_hash);
priv->uri_client_hash = NULL;
@@ -232,7 +224,6 @@ editor_destroy_cb (GtkObject *object, gpointer data)
return;
g_hash_table_remove (priv->uri_client_hash, oc->uri);
- free_client (oc);
}
/* Starts editing an existing component on a client that is already open */
@@ -442,7 +433,6 @@ cal_opened_cb (ECal *client, ECalendarStatus status, gpointer data)
gtk_widget_destroy (dialog);
g_hash_table_remove (priv->uri_client_hash, oc->uri);
- free_client (oc);
}
/* Creates a new OpenClient structure and queues the component editing/creation
diff --git a/composer/ChangeLog b/composer/ChangeLog
index 8f214152da..42e693ff00 100644
--- a/composer/ChangeLog
+++ b/composer/ChangeLog
@@ -1,3 +1,10 @@
+2007-10-02 Matthew Barnes <mbarnes@redhat.com>
+
+ ** Fixes part of bug #469657
+
+ * e-msg-composer.c:
+ Use destroy functions in GHashTables to simplify memory management.
+
2007-09-27 Matthew Barnes <mbarnes@redhat.com>
** Fixes part of bug #477045
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index 3561233eae..232b769270 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -460,15 +460,6 @@ best_charset (GByteArray *buf, const char *default_charset, CamelTransferEncodin
return g_strdup (charset);
}
-static gboolean
-clear_inline_images (gpointer key, gpointer value, gpointer user_data)
-{
- g_free (key);
- camel_object_unref (value);
-
- return TRUE;
-}
-
static void
clear_current_images (EMsgComposer *composer)
{
@@ -477,21 +468,13 @@ clear_current_images (EMsgComposer *composer)
p->current_images = NULL;
}
-static gboolean
-clear_url (gpointer key, gpointer value, gpointer user_data)
-{
- g_free (key);
-
- return TRUE;
-}
-
void
e_msg_composer_clear_inlined_table (EMsgComposer *composer)
{
EMsgComposerPrivate *p = composer->priv;
- g_hash_table_foreach_remove (p->inline_images, clear_inline_images, NULL);
- g_hash_table_foreach_remove (p->inline_images_by_url, clear_url, NULL);
+ g_hash_table_remove_all (p->inline_images);
+ g_hash_table_remove_all (p->inline_images_by_url);
}
static void
@@ -1658,9 +1641,15 @@ static AutosaveManager *
autosave_manager_new ()
{
AutosaveManager *am;
+ GHashTable *table;
+
+ table = g_hash_table_new_full (
+ g_str_hash, g_str_equal,
+ (GDestroyNotify) g_free,
+ (GDestroyNotify) NULL);
am = g_new (AutosaveManager, 1);
- am->table = g_hash_table_new (g_str_hash, g_str_equal);
+ am->table = table;
am->id = 0;
am->ask = TRUE;
@@ -1691,19 +1680,15 @@ autosave_manager_register (AutosaveManager *am, EMsgComposer *composer)
static void
autosave_manager_unregister (AutosaveManager *am, EMsgComposer *composer)
{
- char *key, *oldkey;
- void *olddata;
EMsgComposerPrivate *p = composer->priv;
+ gchar *key;
if (!p->autosave_file)
return;
- key = g_path_get_basename(p->autosave_file);
- if (g_hash_table_lookup_extended(am->table, key, (gpointer)&oldkey, (gpointer)&olddata)) {
- g_hash_table_remove(am->table, oldkey);
- g_free(oldkey);
- g_free(key);
- }
+ key = g_path_get_basename (p->autosave_file);
+ g_hash_table_remove (am->table, key);
+ g_free (key);
/* only remove the file if we can successfully save it */
/* FIXME this test could probably be more efficient */
@@ -2795,7 +2780,6 @@ composer_finalise (GObject *object)
g_ptr_array_free (p->extra_hdr_values, TRUE);
}
- e_msg_composer_clear_inlined_table (composer);
g_hash_table_destroy (p->inline_images);
g_hash_table_destroy (p->inline_images_by_url);
@@ -3354,6 +3338,18 @@ static void
init (EMsgComposer *composer)
{
EMsgComposerPrivate *p = g_new0(EMsgComposerPrivate,1);
+ GHashTable *inline_images;
+ GHashTable *inline_images_by_url;
+
+ inline_images = g_hash_table_new_full (
+ g_str_hash, g_str_equal,
+ (GDestroyNotify) g_free,
+ (GDestroyNotify) NULL);
+
+ inline_images_by_url = g_hash_table_new_full (
+ g_str_hash, g_str_equal,
+ (GDestroyNotify) g_free,
+ (GDestroyNotify) camel_object_unref);
p->uic = NULL;
@@ -3374,8 +3370,8 @@ init (EMsgComposer *composer)
p->persist_stream_interface = CORBA_OBJECT_NIL;
p->eeditor_engine = CORBA_OBJECT_NIL;
- p->inline_images = g_hash_table_new (g_str_hash, g_str_equal);
- p->inline_images_by_url = g_hash_table_new (g_str_hash, g_str_equal);
+ p->inline_images = inline_images;
+ p->inline_images_by_url = inline_images_by_url;
p->current_images = NULL;
p->attachment_bar_visible = FALSE;
@@ -4528,12 +4524,6 @@ set_signature_gui (EMsgComposer *composer)
}
-static void
-auto_recip_free (gpointer key, gpointer value, gpointer user_data)
-{
- g_free (key);
-}
-
/**
* e_msg_composer_new_with_message:
* @message: The message to use as the source
@@ -4599,8 +4589,15 @@ e_msg_composer_new_with_message (CamelMimeMessage *message)
}
if (postto == NULL) {
- auto_cc = g_hash_table_new (camel_strcase_hash, camel_strcase_equal);
- auto_bcc = g_hash_table_new (camel_strcase_hash, camel_strcase_equal);
+ auto_cc = g_hash_table_new_full (
+ camel_strcase_hash, camel_strcase_equal,
+ (GDestroyNotify) g_free,
+ (GDestroyNotify) NULL);
+
+ auto_bcc = g_hash_table_new_full (
+ camel_strcase_hash, camel_strcase_equal,
+ (GDestroyNotify) g_free,
+ (GDestroyNotify) NULL);
if (account) {
CamelInternetAddress *iaddr;
@@ -4672,7 +4669,6 @@ e_msg_composer_new_with_message (CamelMimeMessage *message)
}
Ccv = destination_list_to_vector (Cc);
- g_hash_table_foreach (auto_cc, auto_recip_free, NULL);
g_hash_table_destroy (auto_cc);
g_list_free (Cc);
@@ -4693,7 +4689,6 @@ e_msg_composer_new_with_message (CamelMimeMessage *message)
}
Bccv = destination_list_to_vector (Bcc);
- g_hash_table_foreach (auto_bcc, auto_recip_free, NULL);
g_hash_table_destroy (auto_bcc);
g_list_free (Bcc);
} else {
diff --git a/e-util/ChangeLog b/e-util/ChangeLog
index 95de506f9c..55d29ad7ce 100644
--- a/e-util/ChangeLog
+++ b/e-util/ChangeLog
@@ -1,3 +1,10 @@
+2007-10-02 Matthew Barnes <mbarnes@redhat.com>
+
+ ** Fixes part of bug #469657
+
+ * e-config-listener.c:
+ Use destroy functions in GHashTables to simplify memory management.
+
2007-09-27 Hiroyuki Ikezoe <poincare@ikezoe.net>
** Fix for bug #461195
diff --git a/e-util/e-config-listener.c b/e-util/e-config-listener.c
index 53e2800464..44ed9c0447 100644
--- a/e-util/e-config-listener.c
+++ b/e-util/e-config-listener.c
@@ -71,20 +71,8 @@ e_config_listener_class_init (EConfigListenerClass *klass)
}
static void
-e_config_listener_init (EConfigListener *cl, EConfigListenerClass *klass)
+free_key_data (KeyData *kd)
{
- /* allocate internal structure */
- cl->priv = g_new0 (EConfigListenerPrivate, 1);
-
- cl->priv->keys = g_hash_table_new (g_str_hash, g_str_equal);
- cl->priv->db = gconf_client_get_default ();
-}
-
-static void
-free_key_hash (gpointer key, gpointer value, gpointer user_data)
-{
- KeyData *kd = (KeyData *) value;
-
g_return_if_fail (kd != NULL);
gconf_client_notify_remove (kd->cl->priv->db, kd->lid);
@@ -102,13 +90,25 @@ free_key_hash (gpointer key, gpointer value, gpointer user_data)
}
static void
+e_config_listener_init (EConfigListener *cl, EConfigListenerClass *klass)
+{
+ /* allocate internal structure */
+ cl->priv = g_new0 (EConfigListenerPrivate, 1);
+
+ cl->priv->keys = g_hash_table_new_full (
+ g_str_hash, g_str_equal,
+ (GDestroyNotify) NULL,
+ (GDestroyNotify) free_key_data);
+ cl->priv->db = gconf_client_get_default ();
+}
+
+static void
e_config_listener_finalize (GObject *object)
{
EConfigListener *cl = (EConfigListener *) object;
g_return_if_fail (E_IS_CONFIG_LISTENER (cl));
- g_hash_table_foreach (cl->priv->keys, (GHFunc) free_key_hash, NULL);
g_hash_table_destroy (cl->priv->keys);
cl->priv->keys = NULL;
@@ -256,13 +256,13 @@ e_config_listener_get_boolean_with_default (EConfigListener *cl,
GConfValue *conf_value;
gboolean value;
KeyData *kd;
- gpointer orig_key, orig_value;
g_return_val_if_fail (E_IS_CONFIG_LISTENER (cl), FALSE);
g_return_val_if_fail (key != NULL, FALSE);
/* search for the key in our hash table */
- if (!g_hash_table_lookup_extended (cl->priv->keys, key, &orig_key, &orig_value)) {
+ kd = g_hash_table_lookup (cl->priv->keys, key);
+ if (kd == NULL) {
/* not found, so retrieve it from the configuration database */
conf_value = gconf_client_get (cl->priv->db, key, NULL);
if (conf_value) {
@@ -280,9 +280,6 @@ e_config_listener_get_boolean_with_default (EConfigListener *cl,
*used_default = TRUE;
}
} else {
- kd = (KeyData *) orig_value;
- g_return_val_if_fail (kd != NULL, FALSE);
-
if (kd->type == GCONF_VALUE_BOOL) {
value = kd->value.v_bool;
if (used_default != NULL)
@@ -309,13 +306,13 @@ e_config_listener_get_float_with_default (EConfigListener *cl,
GConfValue *conf_value;
float value;
KeyData *kd;
- gpointer orig_key, orig_value;
g_return_val_if_fail (E_IS_CONFIG_LISTENER (cl), -1);
g_return_val_if_fail (key != NULL, -1);
/* search for the key in our hash table */
- if (!g_hash_table_lookup_extended (cl->priv->keys, key, &orig_key, &orig_value)) {
+ kd = g_hash_table_lookup (cl->priv->keys, key);
+ if (kd == NULL) {
/* not found, so retrieve it from the configuration database */
conf_value = gconf_client_get (cl->priv->db, key, NULL);
if (conf_value) {
@@ -333,9 +330,6 @@ e_config_listener_get_float_with_default (EConfigListener *cl,
*used_default = TRUE;
}
} else {
- kd = (KeyData *) orig_value;
- g_return_val_if_fail (kd != NULL, -1);
-
if (kd->type == GCONF_VALUE_FLOAT) {
value = kd->value.v_float;
if (used_default != NULL)
@@ -362,13 +356,13 @@ e_config_listener_get_long_with_default (EConfigListener *cl,
GConfValue *conf_value;
long value;
KeyData *kd;
- gpointer orig_key, orig_value;
g_return_val_if_fail (E_IS_CONFIG_LISTENER (cl), -1);
g_return_val_if_fail (key != NULL, -1);
/* search for the key in our hash table */
- if (!g_hash_table_lookup_extended (cl->priv->keys, key, &orig_key, &orig_value)) {
+ kd = g_hash_table_lookup (cl->priv->keys, key);
+ if (kd == NULL) {
/* not found, so retrieve it from the configuration database */
conf_value = gconf_client_get (cl->priv->db, key, NULL);
if (conf_value) {
@@ -386,9 +380,6 @@ e_config_listener_get_long_with_default (EConfigListener *cl,
*used_default = TRUE;
}
} else {
- kd = (KeyData *) orig_value;
- g_return_val_if_fail (kd != NULL, -1);
-
if (kd->type == GCONF_VALUE_INT) {
value = kd->value.v_long;
if (used_default != NULL)
@@ -415,13 +406,13 @@ e_config_listener_get_string_with_default (EConfigListener *cl,
GConfValue *conf_value;
char *str;
KeyData *kd;
- gpointer orig_key, orig_value;
g_return_val_if_fail (E_IS_CONFIG_LISTENER (cl), NULL);
g_return_val_if_fail (key != NULL, NULL);
/* search for the key in our hash table */
- if (!g_hash_table_lookup_extended (cl->priv->keys, key, &orig_key, &orig_value)) {
+ kd = g_hash_table_lookup (cl->priv->keys, key);
+ if (kd == NULL) {
/* not found, so retrieve it from the configuration database */
conf_value = gconf_client_get (cl->priv->db, key, NULL);
if (conf_value) {
@@ -439,9 +430,6 @@ e_config_listener_get_string_with_default (EConfigListener *cl,
*used_default = TRUE;
}
} else {
- kd = (KeyData *) orig_value;
- g_return_val_if_fail (kd != NULL, NULL);
-
if (kd->type == GCONF_VALUE_STRING) {
str = g_strdup (kd->value.v_str);
if (used_default != NULL)
@@ -565,23 +553,10 @@ e_config_listener_set_string (EConfigListener *cl, const char *key, const char *
void
e_config_listener_remove_value (EConfigListener *cl, const char *key)
{
- gpointer orig_key, orig_value;
-
g_return_if_fail (E_IS_CONFIG_LISTENER (cl));
g_return_if_fail (key != NULL);
- if (g_hash_table_lookup_extended (cl->priv->keys, key, &orig_key, &orig_value)) {
- KeyData *kd = orig_value;
-
- g_hash_table_remove (cl->priv->keys, key);
- g_free (kd->key);
- if (kd->type == GCONF_VALUE_STRING)
- g_free (kd->value.v_str);
- gconf_client_notify_remove (cl->priv->db, kd->lid);
-
- g_free (kd);
- }
-
+ g_hash_table_remove (cl->priv->keys, key);
gconf_client_unset (cl->priv->db, key, NULL);
}
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);
diff --git a/plugins/exchange-operations/ChangeLog b/plugins/exchange-operations/ChangeLog
index 5c1bef7517..a9d05014d7 100644
--- a/plugins/exchange-operations/ChangeLog
+++ b/plugins/exchange-operations/ChangeLog
@@ -1,3 +1,10 @@
+2007-10-02 Matthew Barnes <mbarnes@redhat.com>
+
+ ** Fixes part of bug #469657
+
+ * exchange-folder-size-display.c:
+ Use destroy functions in GHashTables to simplify memory management.
+
2007-09-27 Matthew Barnes <mbarnes@redhat.com>
** Fixes part of bug #477045
diff --git a/plugins/exchange-operations/exchange-folder-size-display.c b/plugins/exchange-operations/exchange-folder-size-display.c
index e377ce9cd2..c12f1872d9 100644
--- a/plugins/exchange-operations/exchange-folder-size-display.c
+++ b/plugins/exchange-operations/exchange-folder-size-display.c
@@ -41,13 +41,6 @@ enum {
NUM_COLUMNS
};
-static void
-free_entries (gpointer name, gpointer value, gpointer data)
-{
- g_free (name);
- g_free (value);
-}
-
static gboolean
get_folder_size_func (GtkTreeModel *model,
GtkTreePath *path,
@@ -67,17 +60,22 @@ get_folder_size_func (GtkTreeModel *model,
char *
exchange_folder_size_get_val (GtkListStore *model, const char *folder_name)
{
- GHashTable *finfo = g_hash_table_new (g_str_hash, g_str_equal);
+ GHashTable *finfo;
char *folder_size, *fsize;
+ finfo = g_hash_table_new_full (
+ g_str_hash, g_str_equal,
+ (GDestroyNotify) g_free,
+ (GDestroyNotify) g_free);
+
gtk_tree_model_foreach (GTK_TREE_MODEL (model), get_folder_size_func, finfo);
if ((fsize = g_hash_table_lookup (finfo, folder_name)) != NULL)
folder_size = g_strdup (fsize);
else
folder_size = g_strdup ("0");
-
- g_hash_table_foreach (finfo, free_entries, NULL);
+
+ g_hash_table_destroy (finfo);
return folder_size;
}
diff --git a/plugins/mono/ChangeLog b/plugins/mono/ChangeLog
index f668070b8d..0e0b3017c1 100644
--- a/plugins/mono/ChangeLog
+++ b/plugins/mono/ChangeLog
@@ -1,3 +1,10 @@
+2007-10-02 Matthew Barnes <mbarnes@redhat.com>
+
+ ** Fixes part of bug #469657
+
+ * mono-plugin.c:
+ Use destroy functions in GHashTables to simplify memory management.
+
2007-04-02 Sankar P <psankar@novell.com>
* Committed on behalf of Gilles Dartiguelongue <dartigug@esiee.fr>
diff --git a/plugins/mono/mono-plugin.c b/plugins/mono/mono-plugin.c
index a377d0aa34..d945ae5508 100644
--- a/plugins/mono/mono-plugin.c
+++ b/plugins/mono/mono-plugin.c
@@ -152,7 +152,6 @@ epm_finalise(GObject *o)
g_free(epm->location);
g_free(epm->handler);
- g_hash_table_foreach(p->methods, (GHFunc)g_free, NULL);
g_hash_table_destroy(p->methods);
g_free(epm->priv);
@@ -175,7 +174,10 @@ epm_init(GObject *o)
EPlugin *ep = (EPlugin *)o;
epm->priv = g_malloc0(sizeof(*epm->priv));
- epm->priv->methods = g_hash_table_new(g_str_hash, g_str_equal);
+ epm->priv->methods = g_hash_table_new_full(
+ g_str_hash, g_str_equal,
+ (GDestroyNotify) g_free,
+ (GDestroyNotify) NULL);
}
void *
diff --git a/shell/ChangeLog b/shell/ChangeLog
index 5bc2c5ba7c..34db93b399 100644
--- a/shell/ChangeLog
+++ b/shell/ChangeLog
@@ -1,3 +1,10 @@
+2007-10-02 Matthew Barnes <mbarnes@redhat.com>
+
+ ** Fixes part of bug #469657
+
+ * shell/e-shell-settings-dialog.c:
+ Use destroy functions in GHashTables to simplify memory management.
+
2007-09-27 Hiroyuki Ikezoe <poincare@ikezoe.net>
** Fix for bug #461195
diff --git a/shell/e-shell-settings-dialog.c b/shell/e-shell-settings-dialog.c
index e503192034..e2c720355d 100644
--- a/shell/e-shell-settings-dialog.c
+++ b/shell/e-shell-settings-dialog.c
@@ -268,14 +268,6 @@ load_pages (EShellSettingsDialog *dialog)
/* GtkObject methods. */
-static gboolean
-destroy_type_entry (gpointer key, gpointer value, gpointer data)
-{
- g_free (key);
-
- return TRUE;
-}
-
static void
impl_finalize (GObject *object)
{
@@ -285,7 +277,6 @@ impl_finalize (GObject *object)
dialog = E_SHELL_SETTINGS_DIALOG (object);
priv = dialog->priv;
- g_hash_table_foreach_remove (priv->types, destroy_type_entry, NULL);
g_hash_table_destroy (priv->types);
g_free (priv);
@@ -309,7 +300,10 @@ e_shell_settings_dialog_init (EShellSettingsDialog *dialog)
EShellSettingsDialogPrivate *priv;
priv = g_new (EShellSettingsDialogPrivate, 1);
- priv->types = g_hash_table_new (g_str_hash, g_str_equal);
+ priv->types = g_hash_table_new_full (
+ g_str_hash, g_str_equal,
+ (GDestroyNotify) g_free,
+ (GDestroyNotify) NULL);
dialog->priv = priv;
diff --git a/tools/killev.c b/tools/killev.c
index d0b0023278..853f5c4bc0 100644
--- a/tools/killev.c
+++ b/tools/killev.c
@@ -87,10 +87,9 @@ static const char *patterns[] = {
};
static const int n_patterns = G_N_ELEMENTS (patterns);
-static gboolean
-kill_component (gpointer key, gpointer value, gpointer data)
+static void
+kill_component (KillevComponent *comp)
{
- KillevComponent *comp = value;
char *base_name, *exe_name, *dash;
int i;
@@ -101,7 +100,7 @@ kill_component (gpointer key, gpointer value, gpointer data)
if (kill_process (exe_name, comp)) {
g_free (exe_name);
g_free (base_name);
- return TRUE;
+ return;
}
g_free (exe_name);
}
@@ -113,7 +112,6 @@ kill_component (gpointer key, gpointer value, gpointer data)
}
g_free (base_name);
- return TRUE;
}
static void
@@ -200,10 +198,13 @@ main (int argc, char **argv)
while (*language_names != NULL)
languages = g_slist_append (languages, *language_names++);
- components = g_hash_table_new (g_str_hash, g_str_equal);
+ components = g_hash_table_new_full (
+ g_str_hash, g_str_equal,
+ (GDestroyNotify) NULL,
+ (GDestroyNotify) kill_component);
add_matching_repo_id ("IDL:GNOME/Evolution/Shell:" BASE_VERSION);
- g_hash_table_foreach_remove (components, kill_component, NULL);
+ g_hash_table_remove_all (components);
add_matching_repo_id ("IDL:GNOME/Evolution/Component:" BASE_VERSION);
add_matching_repo_id ("IDL:GNOME/Evolution/DataServer/CalFactory:" DATASERVER_API_VERSION);
@@ -214,8 +215,9 @@ main (int argc, char **argv)
add_matching_iid ("OAFIID:GNOME_Evolution_Calendar_AlarmNotify_Factory:" BASE_VERSION);
add_matching_iid ("OAFIID:GNOME_GtkHTML_Editor_Factory:3.1");
+ g_hash_table_remove_all (components);
- g_hash_table_foreach_remove (components, kill_component, NULL);
+ g_hash_table_destroy (components);
return 0;
}
diff --git a/widgets/table/ChangeLog b/widgets/table/ChangeLog
index 764d76c139..2ee5268d62 100644
--- a/widgets/table/ChangeLog
+++ b/widgets/table/ChangeLog
@@ -1,3 +1,11 @@
+2007-10-02 Matthew Barnes <mbarnes@redhat.com>
+
+ ** Fixes part of bug #469657
+
+ * e-table-extras.c:
+ * e-table-selection-model.c:
+ Use destroy functions in GHashTables to simplify memory management.
+
2007-10-01 Milan Crha <mcrha@redhat.com>
** Fix for bug #470837
diff --git a/widgets/table/e-table-extras.c b/widgets/table/e-table-extras.c
index 312e19a0c5..25fb69e322 100644
--- a/widgets/table/e-table-extras.c
+++ b/widgets/table/e-table-extras.c
@@ -44,16 +44,6 @@
G_DEFINE_TYPE (ETableExtras, ete, G_TYPE_OBJECT)
static void
-cell_hash_free(gchar *key,
- ECell *cell,
- gpointer user_data)
-{
- g_free(key);
- if (cell)
- g_object_unref(cell);
-}
-
-static void
pixbuf_hash_free(gchar *key,
GdkPixbuf *pixbuf,
gpointer user_data)
@@ -69,30 +59,25 @@ ete_finalize (GObject *object)
ETableExtras *ete = E_TABLE_EXTRAS (object);
if (ete->cells) {
- g_hash_table_foreach (ete->cells, (GHFunc) cell_hash_free, NULL);
g_hash_table_destroy (ete->cells);
+ ete->cells = NULL;
}
if (ete->compares) {
- g_hash_table_foreach (ete->compares, (GHFunc) g_free, NULL);
g_hash_table_destroy (ete->compares);
+ ete->compares = NULL;
}
if (ete->searches) {
- g_hash_table_foreach (ete->searches, (GHFunc) g_free, NULL);
g_hash_table_destroy (ete->searches);
+ ete->searches = NULL;
}
if (ete->pixbufs) {
- g_hash_table_foreach (ete->pixbufs, (GHFunc) pixbuf_hash_free, NULL);
g_hash_table_destroy (ete->pixbufs);
+ ete->pixbufs = NULL;
}
- ete->cells = NULL;
- ete->compares = NULL;
- ete->searches = NULL;
- ete->pixbufs = NULL;
-
G_OBJECT_CLASS (ete_parent_class)->finalize (object);
}
@@ -162,12 +147,34 @@ e_string_search(gconstpointer haystack, const char *needle)
}
static void
+safe_unref (gpointer object)
+{
+ if (object != NULL)
+ g_object_unref (object);
+}
+
+static void
ete_init (ETableExtras *extras)
{
- extras->cells = g_hash_table_new(g_str_hash, g_str_equal);
- extras->compares = g_hash_table_new(g_str_hash, g_str_equal);
- extras->searches = g_hash_table_new(g_str_hash, g_str_equal);
- extras->pixbufs = g_hash_table_new(g_str_hash, g_str_equal);
+ extras->cells = g_hash_table_new_full (
+ g_str_hash, g_str_equal,
+ (GDestroyNotify) g_free,
+ (GDestroyNotify) safe_unref);
+
+ extras->compares = g_hash_table_new_full (
+ g_str_hash, g_str_equal,
+ (GDestroyNotify) g_free,
+ (GDestroyNotify) NULL);
+
+ extras->searches = g_hash_table_new_full (
+ g_str_hash, g_str_equal,
+ (GDestroyNotify) g_free,
+ (GDestroyNotify) NULL);
+
+ extras->pixbufs = g_hash_table_new_full (
+ g_str_hash, g_str_equal,
+ (GDestroyNotify) g_free,
+ (GDestroyNotify) safe_unref);
e_table_extras_add_compare(extras, "string", e_str_compare);
e_table_extras_add_compare(extras, "stringcase", e_str_case_compare);
@@ -199,16 +206,6 @@ e_table_extras_add_cell (ETableExtras *extras,
char *id,
ECell *cell)
{
- gchar *old_key;
- ECell *old_cell;
-
- if (g_hash_table_lookup_extended (extras->cells, id, (gpointer *)&old_key, (gpointer *)&old_cell)) {
- g_hash_table_remove (extras->cells, old_key);
- g_free (old_key);
- if (old_cell)
- g_object_unref (old_cell);
- }
-
if (cell)
g_object_ref_sink (cell);
g_hash_table_insert (extras->cells, g_strdup(id), cell);
@@ -226,14 +223,6 @@ e_table_extras_add_compare (ETableExtras *extras,
char *id,
GCompareFunc compare)
{
- gchar *old_key;
- GCompareFunc old_compare;
-
- if (g_hash_table_lookup_extended (extras->compares, id, (gpointer *)&old_key, (gpointer *)&old_compare)) {
- g_hash_table_remove (extras->compares, old_key);
- g_free (old_key);
- }
-
g_hash_table_insert(extras->compares, g_strdup(id), (gpointer) compare);
}
@@ -249,14 +238,6 @@ e_table_extras_add_search (ETableExtras *extras,
char *id,
ETableSearchFunc search)
{
- gchar *old_key;
- ETableSearchFunc old_search;
-
- if (g_hash_table_lookup_extended (extras->searches, id, (gpointer *)&old_key, (gpointer *)&old_search)) {
- g_hash_table_remove (extras->searches, old_key);
- g_free (old_key);
- }
-
g_hash_table_insert(extras->searches, g_strdup(id), search);
}
@@ -272,16 +253,6 @@ e_table_extras_add_pixbuf (ETableExtras *extras,
char *id,
GdkPixbuf *pixbuf)
{
- gchar *old_key;
- GdkPixbuf *old_pixbuf;
-
- if (g_hash_table_lookup_extended (extras->pixbufs, id, (gpointer *)&old_key, (gpointer *)&old_pixbuf)) {
- g_hash_table_remove (extras->cells, old_key);
- g_free (old_key);
- if (old_pixbuf)
- g_object_unref (old_pixbuf);
- }
-
if (pixbuf)
g_object_ref(pixbuf);
g_hash_table_insert (extras->pixbufs, g_strdup(id), pixbuf);
diff --git a/widgets/table/e-table-selection-model.c b/widgets/table/e-table-selection-model.c
index 76983106f6..2b8ec0fa99 100644
--- a/widgets/table/e-table-selection-model.c
+++ b/widgets/table/e-table-selection-model.c
@@ -52,16 +52,9 @@ save_to_hash(int model_row, gpointer closure)
}
static void
-free_key(gpointer key, gpointer value, gpointer closure)
-{
- g_free(key);
-}
-
-static void
free_hash(ETableSelectionModel *etsm)
{
if (etsm->hash) {
- g_hash_table_foreach(etsm->hash, free_key, NULL);
g_hash_table_destroy(etsm->hash);
etsm->hash = NULL;
}
@@ -78,7 +71,10 @@ model_pre_change (ETableModel *etm, ETableSelectionModel *etsm)
if (etsm->model && e_table_model_has_save_id (etsm->model)) {
gint cursor_row;
- etsm->hash = g_hash_table_new(g_str_hash, g_str_equal);
+ etsm->hash = g_hash_table_new_full(
+ g_str_hash, g_str_equal,
+ (GDestroyNotify) g_free,
+ (GDestroyNotify) NULL);
e_selection_model_foreach(E_SELECTION_MODEL(etsm), save_to_hash, etsm);
g_object_get(etsm,