[gnome-initial-setup/auto-free-things: 1/3] Use g_auto()/g_autoptr() more
- From: Matthew Leeds <mwleeds src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-initial-setup/auto-free-things: 1/3] Use g_auto()/g_autoptr() more
- Date: Wed, 18 Mar 2020 21:42:14 +0000 (UTC)
commit 93d60570e5084f5282e3d57c8e0d4c23d41c0f00
Author: Matthew Leeds <matthew leeds endlessm com>
Date: Wed Mar 18 14:32:28 2020 -0700
Use g_auto()/g_autoptr() more
We already depend on a new enough GLib for these.
gnome-initial-setup/gis-keyring.c | 18 +++++-------------
.../pages/language/cc-language-chooser.c | 6 ++----
.../pages/language/gis-welcome-widget.c | 4 +---
3 files changed, 8 insertions(+), 20 deletions(-)
---
diff --git a/gnome-initial-setup/gis-keyring.c b/gnome-initial-setup/gis-keyring.c
index 16e2d3c..e8ee2ef 100644
--- a/gnome-initial-setup/gis-keyring.c
+++ b/gnome-initial-setup/gis-keyring.c
@@ -42,30 +42,22 @@
void
gis_ensure_login_keyring ()
{
- GSubprocess *subprocess = NULL;
- GSubprocessLauncher *launcher = NULL;
- GError *error = NULL;
+ g_autoptr(GSubprocess) subprocess = NULL;
+ g_autoptr(GSubprocessLauncher) launcher = NULL;
+ g_autoptr(GError) error = NULL;
g_debug ("launching gnome-keyring-daemon --unlock");
launcher = g_subprocess_launcher_new (G_SUBPROCESS_FLAGS_STDIN_PIPE | G_SUBPROCESS_FLAGS_STDOUT_PIPE
| G_SUBPROCESS_FLAGS_STDERR_SILENCE);
subprocess = g_subprocess_launcher_spawn (launcher, &error, "gnome-keyring-daemon", "--unlock", NULL);
if (subprocess == NULL) {
g_warning ("Failed to spawn gnome-keyring-daemon --unlock: %s", error->message);
- g_error_free (error);
- goto out;
+ return;
}
if (!g_subprocess_communicate_utf8 (subprocess, DUMMY_PWD, NULL, NULL, NULL, &error)) {
g_warning ("Failed to communicate with gnome-keyring-daemon: %s", error->message);
- g_error_free (error);
- goto out;
+ return;
}
-
-out:
- if (subprocess)
- g_object_unref (subprocess);
- if (launcher)
- g_object_unref (launcher);
}
void
diff --git a/gnome-initial-setup/pages/language/cc-language-chooser.c
b/gnome-initial-setup/pages/language/cc-language-chooser.c
index 3722de1..fa8531c 100644
--- a/gnome-initial-setup/pages/language/cc-language-chooser.c
+++ b/gnome-initial-setup/pages/language/cc-language-chooser.c
@@ -296,14 +296,12 @@ add_languages (CcLanguageChooser *chooser,
static void
add_all_languages (CcLanguageChooser *chooser)
{
- char **locale_ids;
- GHashTable *initial;
+ g_auto(GStrv) locale_ids = NULL;
+ g_autoptr(GHashTable) initial = NULL;
locale_ids = gnome_get_all_locales ();
initial = cc_common_language_get_initial_languages ();
add_languages (chooser, locale_ids, initial);
- g_hash_table_destroy (initial);
- g_strfreev (locale_ids);
}
static gboolean
diff --git a/gnome-initial-setup/pages/language/gis-welcome-widget.c
b/gnome-initial-setup/pages/language/gis-welcome-widget.c
index 7f030bd..675da33 100644
--- a/gnome-initial-setup/pages/language/gis-welcome-widget.c
+++ b/gnome-initial-setup/pages/language/gis-welcome-widget.c
@@ -158,7 +158,7 @@ fill_stack (GisWelcomeWidget *widget)
GHashTable *initial = cc_common_language_get_initial_languages ();
GHashTableIter iter;
gpointer key, value;
- GHashTable *added_translations;
+ g_autoptr(GHashTable) added_translations = NULL;
added_translations = g_hash_table_new (g_str_hash, g_str_equal);
@@ -183,8 +183,6 @@ fill_stack (GisWelcomeWidget *widget)
g_hash_table_insert (priv->translation_widgets, locale_id, label);
}
-
- g_hash_table_destroy (added_translations);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]