[gtranslator] Use g_(s)list_free_full where appropiate
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtranslator] Use g_(s)list_free_full where appropiate
- Date: Mon, 8 Nov 2010 09:23:48 +0000 (UTC)
commit e0adc2ccdd87ad7e6761e285abcfc7b1426c413a
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Sat Nov 6 19:34:39 2010 +0100
Use g_(s)list_free_full where appropiate
src/dialogs/gtr-assistant.c | 3 +--
src/dialogs/gtr-preferences-dialog.c | 4 ++--
src/gtr-actions-file.c | 6 ++----
src/gtr-po.c | 13 ++-----------
src/gtr-profile-manager.c | 13 ++++---------
src/gtr-utils.c | 4 ++--
src/gtr-window.c | 6 ++----
src/translation-memory/gda/gtr-gda.c | 7 ++++---
src/translation-memory/gtr-translation-memory-ui.c | 6 ++----
9 files changed, 21 insertions(+), 41 deletions(-)
---
diff --git a/src/dialogs/gtr-assistant.c b/src/dialogs/gtr-assistant.c
index 0f9866a..13ac147 100644
--- a/src/dialogs/gtr-assistant.c
+++ b/src/dialogs/gtr-assistant.c
@@ -158,8 +158,7 @@ destroy_idle_data (gpointer data)
gtk_widget_hide (GTK_WIDGET (d->progress));
- g_slist_foreach (d->list, (GFunc) g_object_unref, NULL);
- g_slist_free (d->list);
+ g_slist_free_full (d->list, g_object_unref);
gtk_widget_destroy (GTK_WIDGET (d->parent));
diff --git a/src/dialogs/gtr-preferences-dialog.c b/src/dialogs/gtr-preferences-dialog.c
index df5c0ea..986f255 100644
--- a/src/dialogs/gtr-preferences-dialog.c
+++ b/src/dialogs/gtr-preferences-dialog.c
@@ -816,8 +816,8 @@ destroy_idle_data (gpointer data)
IdleData *d = (IdleData *) data;
gtk_widget_hide (GTK_WIDGET (d->progress));
- g_slist_foreach (d->list, (GFunc) g_object_unref, NULL);
- g_slist_free (d->list);
+
+ g_slist_free_full (d->list, g_object_unref);
g_free (d);
}
diff --git a/src/gtr-actions-file.c b/src/gtr-actions-file.c
index ab67894..6725c9f 100644
--- a/src/gtr-actions-file.c
+++ b/src/gtr-actions-file.c
@@ -132,8 +132,7 @@ gtr_po_parse_files_from_dialog (GtkWidget * dialog, GtrWindow * window)
* We store latest directory
*/
file = g_file_new_for_uri (po_files->data);
- g_slist_foreach (po_files, (GFunc) g_free, NULL);
- g_slist_free (po_files);
+ g_slist_free_full (po_files, g_free);
parent = g_file_get_parent (file);
g_object_unref (file);
@@ -148,8 +147,7 @@ gtr_po_parse_files_from_dialog (GtkWidget * dialog, GtrWindow * window)
* Open the file via our centralized opening function.
*/
load_file_list (window, (const GSList *) locations);
- g_slist_foreach (locations, (GFunc) g_object_unref, NULL);
- g_slist_free (locations);
+ g_slist_free_full (locations, g_object_unref);
/*
* Destroy the dialog
diff --git a/src/gtr-po.c b/src/gtr-po.c
index 1db941f..e941706 100644
--- a/src/gtr-po.c
+++ b/src/gtr-po.c
@@ -188,17 +188,8 @@ gtr_po_finalize (GObject * object)
{
GtrPo *po = GTR_PO (object);
- if (po->priv->messages)
- {
- g_list_foreach (po->priv->messages, (GFunc) g_object_unref, NULL);
- g_list_free (po->priv->messages);
- }
- if (po->priv->domains)
- {
- g_list_foreach (po->priv->domains, (GFunc) g_free, NULL);
- g_list_free (po->priv->domains);
- }
-
+ g_list_free_full (po->priv->messages, g_object_unref);
+ g_list_free_full (po->priv->domains, g_free);
g_free (po->priv->obsolete);
if (po->priv->gettext_po_file)
diff --git a/src/gtr-profile-manager.c b/src/gtr-profile-manager.c
index f0a55d4..103ff8a 100644
--- a/src/gtr-profile-manager.c
+++ b/src/gtr-profile-manager.c
@@ -62,18 +62,13 @@ get_profile_filename ()
}
static void
-gtr_profile_manager_dispose (GObject *object)
+gtr_profile_manager_finalize (GObject *object)
{
GtrProfileManager *manager = GTR_PROFILE_MANAGER (object);
- if (manager->priv->profiles != NULL)
- {
- g_slist_foreach (manager->priv->profiles, (GFunc) g_object_unref, NULL);
- g_slist_free (manager->priv->profiles);
- manager->priv->profiles = NULL;
- }
+ g_slist_free_full (manager->priv->profiles, g_object_unref);
- G_OBJECT_CLASS (gtr_profile_manager_parent_class)->dispose (object);
+ G_OBJECT_CLASS (gtr_profile_manager_parent_class)->finalize (object);
}
static void
@@ -81,7 +76,7 @@ gtr_profile_manager_class_init (GtrProfileManagerClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->dispose = gtr_profile_manager_dispose;
+ object_class->finalize = gtr_profile_manager_finalize;
g_type_class_add_private (object_class, sizeof (GtrProfileManagerPrivate));
diff --git a/src/gtr-utils.c b/src/gtr-utils.c
index 297b619..7837326 100644
--- a/src/gtr-utils.c
+++ b/src/gtr-utils.c
@@ -823,8 +823,8 @@ gtr_utils_get_current_year (void)
* @po_name: the name of the specific po file to search or NULL.
*
* Scans the directory and subdirectories of @dir looking for filenames remained
- * with .po or files that matches @po_name. The contents of @list must be freed with
- * g_slist_foreach (list, (GFunc)g_object_unref, NULL).
+ * with .po or files that matches @po_name. @list must be freed with
+ * g_slist_free_full (list, g_object_unref).
*/
void
gtr_utils_scan_dir (GFile * dir, GSList ** list, const gchar * po_name)
diff --git a/src/gtr-window.c b/src/gtr-window.c
index a7ddb57..a3a2ef5 100644
--- a/src/gtr-window.c
+++ b/src/gtr-window.c
@@ -919,8 +919,7 @@ drag_data_received_cb (GtkWidget * widget,
locations = gtr_utils_drop_get_locations (selection_data);
gtr_actions_load_locations (window, locations);
- g_slist_foreach (locations, (GFunc) g_object_unref, NULL);
- g_slist_free (locations);
+ g_slist_free_full (locations, g_object_unref);
}
}
@@ -1299,8 +1298,7 @@ gtr_recent_chooser_item_activated_cb (GtkRecentChooser * chooser,
list = g_slist_prepend (list, location);
gtr_actions_load_locations (window, list);
- g_slist_foreach (list, (GFunc) g_object_unref, NULL);
- g_slist_free (list);
+ g_slist_free_full (list, g_object_unref);
}
static GtkWidget *
diff --git a/src/translation-memory/gda/gtr-gda.c b/src/translation-memory/gda/gtr-gda.c
index d7b8e46..9a31481 100644
--- a/src/translation-memory/gda/gtr-gda.c
+++ b/src/translation-memory/gda/gtr-gda.c
@@ -468,8 +468,10 @@ gtr_gda_remove (GtrTranslationMemory *tm,
}
static void
-free_match (GtrTranslationMemoryMatch *match, gpointer dummy)
+free_match (gpointer data)
{
+ GtrTranslationMemoryMatch *match = (GtrTranslationMemoryMatch *) data;
+
g_free (match->match);
g_slice_free (GtrTranslationMemoryMatch, match);
}
@@ -671,8 +673,7 @@ gtr_gda_lookup (GtrTranslationMemory * tm, const gchar * phrase)
if (inner_error)
{
- g_list_foreach (matches, (GFunc) free_match, NULL);
- g_list_free (matches);
+ g_list_free_full (matches, free_match);
g_warning ("%s\n", inner_error->message);
diff --git a/src/translation-memory/gtr-translation-memory-ui.c b/src/translation-memory/gtr-translation-memory-ui.c
index 0835fde..ae01a70 100644
--- a/src/translation-memory/gtr-translation-memory-ui.c
+++ b/src/translation-memory/gtr-translation-memory-ui.c
@@ -115,7 +115,7 @@ on_activate_item_cb (GtkMenuItem * menuitem,
}
static void
-free_list (gpointer data, gpointer useless)
+free_match (gpointer data)
{
GtrTranslationMemoryMatch *match = (GtrTranslationMemoryMatch *) data;
@@ -253,9 +253,7 @@ showed_message_cb (GtrTab * tab, GtrMsg * msg, GtrTranslationMemoryUi * tm_ui)
gtk_menu_item_set_submenu (GTK_MENU_ITEM (tm_menu), items_menu);
- /* Freeing the list */
- g_list_foreach (tm_list, (GFunc) free_list, NULL);
- g_list_free (tm_list);
+ g_list_free_full (tm_list, free_match);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]