diff --git a/src/gtr-drop-down-option.c b/src/gtr-drop-down-option.c index bb642a5fc9bff0a99f169d1fcfd12c631baf4330..71ea04aea3f21e6fbc81ffaaa4d980f84e441d24 100644 --- a/src/gtr-drop-down-option.c +++ b/src/gtr-drop-down-option.c @@ -47,8 +47,8 @@ gtr_drop_down_option_finalize (GObject *object) { GtrDropDownOption *option = GTR_DROP_DOWN_OPTION (object); - g_free (option->name); - g_free (option->description); + g_clear_pointer (&option->name, g_free); + g_clear_pointer (&option->description, g_free); G_OBJECT_CLASS (gtr_drop_down_option_parent_class)->finalize (object); } @@ -140,7 +140,7 @@ gtr_drop_down_option_new (const char *name, const char *description) gboolean gtr_drop_down_option_equal (GtrDropDownOption *opt1, GtrDropDownOption *opt2) { - if (strcmp (opt1->name, opt2->name)) + if (g_strcmp0 (opt1->name, opt2->name)) return FALSE; return TRUE; } diff --git a/src/gtr-header.c b/src/gtr-header.c index 31690eaf108de38e56e05ee1c50149561ee0a45c..a0eaf043061caea24d45f31a1a3068fcbb76753f 100644 --- a/src/gtr-header.c +++ b/src/gtr-header.c @@ -673,21 +673,16 @@ set_profile_values (GtrHeader *header) static void update_po_date (GtrHeader * header) { - gchar *current_date; - gchar *current_time; - gchar *new_date; + g_autofree char *current_date; + g_autofree char *current_time; + g_autofree char *new_date; current_date = gtr_utils_get_current_date (); current_time = gtr_utils_get_current_time (); new_date = g_strconcat (current_date, " ", current_time, NULL); - g_free (current_date); - g_free (current_time); - gtr_header_set_po_date (header, new_date); - - g_free (new_date); } static void @@ -778,7 +773,7 @@ update_comments (GtrHeader *header, const gchar *comments) if (*search != '\0' && strcmp (search, current_year) != 0) { - first_year = g_strdup (search); + g_set_str (&first_year, search); g_free (search); break; } diff --git a/src/gtr-po.c b/src/gtr-po.c index c65ca34b6d8c89bc96a7fd61bca41d41808a466b..76114bcc2951f319a0cd91cabdc90b4a8692d8f9 100644 --- a/src/gtr-po.c +++ b/src/gtr-po.c @@ -385,8 +385,8 @@ static gboolean is_read_only (const gchar * filename) { gboolean ret = TRUE; /* default to read only */ - GFileInfo *info; - GFile *location; + g_autoptr (GFileInfo) info = NULL; + g_autoptr (GFile) location = NULL; location = g_file_new_for_path (filename); @@ -396,18 +396,9 @@ is_read_only (const gchar * filename) info = g_file_query_info (location, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE, G_FILE_QUERY_INFO_NONE, NULL, NULL); - g_object_unref (location); - - if (info != NULL) - { - if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE)) - { - ret = !g_file_info_get_attribute_boolean (info, - G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE); - } - g_object_unref (info); - } + if (info != NULL && g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE)) + ret = !g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE); return ret; } diff --git a/src/gtr-profile.c b/src/gtr-profile.c index d8b6cf99a64d02dd9519a1d4cb1546336bb30f53..36a8049e8345b5809d24a59dd0bf58afcadd81e4 100644 --- a/src/gtr-profile.c +++ b/src/gtr-profile.c @@ -71,16 +71,16 @@ gtr_profile_finalize (GObject *object) GtrProfile *profile = GTR_PROFILE (object); GtrProfilePrivate *priv = gtr_profile_get_instance_private (profile); - g_free (priv->name); - g_free (priv->auth_token); - g_free (priv->author_name); - g_free (priv->author_email); - g_free (priv->language_name); - g_free (priv->language_code); - g_free (priv->charset); - g_free (priv->encoding); - g_free (priv->group_email); - g_free (priv->plural_forms); + g_clear_pointer (&priv->name, g_free); + g_clear_pointer (&priv->auth_token, g_free); + g_clear_pointer (&priv->author_name, g_free); + g_clear_pointer (&priv->author_email, g_free); + g_clear_pointer (&priv->language_name, g_free); + g_clear_pointer (&priv->language_code, g_free); + g_clear_pointer (&priv->charset, g_free); + g_clear_pointer (&priv->encoding, g_free); + g_clear_pointer (&priv->group_email, g_free); + g_clear_pointer (&priv->plural_forms, g_free); G_OBJECT_CLASS (gtr_profile_parent_class)->finalize (object); } diff --git a/src/gtr-utils.c b/src/gtr-utils.c index 2b4ffbeee80be9d81ff91f2c78ea8e8137f543b9..361893ec9243a85260dbf3ecfd5f093c563e76e3 100644 --- a/src/gtr-utils.c +++ b/src/gtr-utils.c @@ -252,19 +252,14 @@ void gtr_utils_help_display (GtkWindow * window) { GdkDisplay *display; - GAppLaunchContext *context; + g_autoptr (GAppLaunchContext) context = NULL; display = gtk_widget_get_display (GTK_WIDGET (window)); if (display != NULL) context = G_APP_LAUNCH_CONTEXT (gdk_display_get_app_launch_context (display)); - else - context = NULL; g_app_info_launch_default_for_uri_async ("help:gtranslator", context, NULL, on_uri_launch, NULL); - - if (context) - g_object_unref (context); } gchar *