Commit 8345a55d authored by Mario Sanchez Prada's avatar Mario Sanchez Prada

Use g_autoptr, g_auto and g_autofree whenever possible

This will make the code more compact and less prone to leaking memory,
by requiring to bump the required versions of GTK+ and JSON-GLib.
parent 13d1b810
......@@ -4,6 +4,7 @@
* Migrated to the meson and ninja, removed all the autotools files.
* Fixed integration with GNOME Software (appstream data).
* Fixed errors loading images from certain cameras / phones (#768639, #678241).
* Raised versions for GTK+ (to 3.16) and JSON-GLib (to 1.2), for g_autoptr.
New and updated translations:
......
......@@ -24,12 +24,12 @@ frogr_conf.set_quoted('LOCALEDIR', join_paths(prefix, localedir))
compiler = meson.get_compiler('c')
# Dependencies
gtk_ver = '3.4'
gtk_ver = '3.16'
glib_ver = '2.44'
soup_ver = '2.34'
exif_ver = '0.6.14'
xml2_ver = '2.6.8'
json_glib_ver = '0.12'
json_glib_ver = '1.2'
gcrypt_ver = '1.5.0'
glib = dependency('glib-2.0', version: '>=@0@'.format(glib_ver))
......
......@@ -77,7 +77,7 @@ upload_cb (GObject *object,
gpointer source_func)
{
FspSession *session = FSP_SESSION (object);
GError *error = NULL;
g_autoptr(GError) error = NULL;
g_free (uploaded_photo_id);
uploaded_photo_id = fsp_session_upload_finish (session, res, &error);
......@@ -85,7 +85,6 @@ upload_cb (GObject *object,
if (error != NULL)
{
g_print ("Error uploading picture: %s\n", error->message);
g_error_free (error);
}
else
{
......@@ -130,14 +129,13 @@ added_to_group_cb (GObject *object,
gpointer user_data)
{
FspSession *session = FSP_SESSION (object);
GError *error = NULL;
g_autoptr(GError) error = NULL;
gboolean result = FALSE;
result = fsp_session_add_to_group_finish (session, res, &error);
if (error != NULL)
{
g_print ("Error creating group: %s\n", error->message);
g_error_free (error);
}
else
{
......@@ -152,14 +150,13 @@ get_groups_cb (GObject *object,
gpointer user_data)
{
FspSession *session = FSP_SESSION (object);
GError *error = NULL;
GSList *groups_list = NULL;
g_autoptr(GError) error = NULL;
g_autoptr(GSList) groups_list = NULL;
groups_list = fsp_session_get_groups_finish (session, res, &error);
if (error != NULL)
{
g_print ("Error getting groups: %s\n", error->message);
g_error_free (error);
}
else
{
......@@ -203,8 +200,6 @@ get_groups_cb (GObject *object,
FSP_SEARCH_SCOPE_NONE,
NULL, upload_cb,
(gpointer) get_groups_cb);
g_slist_free (groups_list);
}
}
......@@ -214,14 +209,13 @@ added_to_photoset_cb (GObject *object,
gpointer user_data)
{
FspSession *session = FSP_SESSION (object);
GError *error = NULL;
g_autoptr(GError) error = NULL;
gboolean result = FALSE;
result = fsp_session_add_to_photoset_finish (session, res, &error);
if (error != NULL)
{
g_print ("Error adding to photoset: %s\n", error->message);
g_error_free (error);
}
else
{
......@@ -245,14 +239,13 @@ photoset_created_cb (GObject *object,
gpointer user_data)
{
FspSession *session = FSP_SESSION (object);
GError *error = NULL;
g_autoptr(GError) error = NULL;
created_photoset_id =
fsp_session_create_photoset_finish (session, res, &error);
if (error != NULL)
{
g_print ("Error creating photoset: %s\n", error->message);
g_error_free (error);
}
else
{
......@@ -285,14 +278,13 @@ get_photosets_cb (GObject *object,
gpointer user_data)
{
FspSession *session = FSP_SESSION (object);
GError *error = NULL;
GSList *photosets_list =
g_autoptr(GError) error = NULL;
g_autoptr(GSList) photosets_list =
fsp_session_get_photosets_finish (session, res, &error);
if (error != NULL)
{
g_print ("Error getting photosets: %s\n", error->message);
g_error_free (error);
}
else
{
......@@ -325,7 +317,6 @@ get_photosets_cb (GObject *object,
"Photoset's description\nasdasda",
uploaded_photo_id,
NULL, photoset_created_cb, NULL);
g_slist_free (photosets_list);
}
}
......@@ -335,14 +326,13 @@ photo_get_info_cb (GObject *object,
gpointer user_data)
{
FspSession *session = FSP_SESSION (object);
GError *error = NULL;
g_autoptr(GError) error = NULL;
FspDataPhotoInfo *photo_info =
fsp_session_get_info_finish (session, res, &error);
if (error != NULL)
{
g_print ("Error uploading picture: %s\n", error->message);
g_error_free (error);
}
else
{
......@@ -387,14 +377,13 @@ set_date_posted_cb (GObject *object,
gpointer user_data)
{
FspSession *session = FSP_SESSION (object);
GError *error = NULL;
g_autoptr(GError) error = NULL;
gboolean result = FALSE;
result = fsp_session_set_date_posted_finish (session, res, &error);
if (error != NULL)
{
g_print ("Error setting the date posted: %s\n", error->message);
g_error_free (error);
}
else
{
......@@ -418,20 +407,19 @@ get_location_cb (GObject *object,
gpointer user_data)
{
FspSession *session = FSP_SESSION (object);
GError *error = NULL;
g_autoptr(GError) error = NULL;
FspDataLocation *location = NULL;
location = fsp_session_get_location_finish (session, res, &error);
if (error != NULL)
{
g_print ("Error getting location: %s\n", error->message);
g_error_free (error);
}
else
{
GDateTime *date_now = NULL;
GDateTime *date = NULL;
gchar* date_str = NULL;
g_autofree gchar* date_str = NULL;
g_print ("[get_location_cb]::Success! Location got:\n");
g_print ("[get_location_cb]::\tLatitude: %g\n", location->latitude);
......@@ -450,7 +438,6 @@ get_location_cb (GObject *object,
fsp_session_set_date_posted (session, uploaded_photo_id, date, NULL,
set_date_posted_cb, NULL);
g_free (date_str);
g_date_time_unref (date);
g_date_time_unref (date_now);
......@@ -465,14 +452,13 @@ set_location_cb (GObject *object,
gpointer user_data)
{
FspSession *session = FSP_SESSION (object);
GError *error = NULL;
g_autoptr(GError) error = NULL;
gboolean result = FALSE;
result = fsp_session_set_location_finish (session, res, &error);
if (error != NULL)
{
g_print ("Error setting location: %s\n", error->message);
g_error_free (error);
}
else
{
......@@ -496,14 +482,13 @@ set_license_cb (GObject *object,
gpointer user_data)
{
FspSession *session = FSP_SESSION (object);
GError *error = NULL;
g_autoptr(GError) error = NULL;
gboolean result = FALSE;
result = fsp_session_set_license_finish (session, res, &error);
if (error != NULL)
{
g_print ("Error setting license: %s\n", error->message);
g_error_free (error);
}
else
{
......@@ -538,14 +523,13 @@ void
get_tags_list_cb (GObject *object, GAsyncResult *res, gpointer unused)
{
FspSession* session = FSP_SESSION (object);
GSList *tags_list = NULL;
GError *error = NULL;
g_autoptr(GSList) tags_list = NULL;
g_autoptr(GError) error = NULL;
tags_list = fsp_session_get_tags_list_finish (session, res, &error);
if (error != NULL)
{
g_print ("Error retrieving tags: %s\n", error->message);
g_error_free (error);
}
else
{
......@@ -561,7 +545,6 @@ get_tags_list_cb (GObject *object, GAsyncResult *res, gpointer unused)
g_print ("[get_tags_list_cb]::\tTag: %s\n", tag);
g_free (tag);
}
g_slist_free (tags_list);
/* Make a pause before continuing */
g_print ("Press ENTER to continue...\n\n");
......@@ -594,13 +577,12 @@ get_upload_status_cb (GObject *object, GAsyncResult *res, gpointer unused)
{
FspSession* session = FSP_SESSION (object);
FspDataUploadStatus *upload_status = NULL;
GError *error = NULL;
g_autoptr(GError) error = NULL;
upload_status = fsp_session_get_upload_status_finish (session, res, &error);
if (error != NULL)
{
g_print ("Error retrieving upload status: %s\n", error->message);
g_error_free (error);
}
else
{
......@@ -639,13 +621,12 @@ check_auth_info_cb (GObject *object, GAsyncResult *res, gpointer unused)
{
FspSession* session = FSP_SESSION (object);
FspDataAuthToken *auth_token = NULL;
GError *error = NULL;
g_autoptr(GError) error = NULL;
auth_token = fsp_session_check_auth_info_finish (session, res, &error);
if (error != NULL)
{
g_print ("Error checking authorization information: %s\n", error->message);
g_error_free (error);
}
else
{
......@@ -677,13 +658,12 @@ complete_auth_cb (GObject *object,
{
FspSession* session = FSP_SESSION (object);
FspDataAuthToken *auth_token = NULL;
GError *error = NULL;
g_autoptr(GError) error = NULL;
auth_token = fsp_session_complete_auth_finish (session, res, &error);
if (error != NULL)
{
g_print ("Error completing authorization: %s\n", error->message);
g_error_free (error);
}
else
{
......@@ -715,13 +695,12 @@ get_auth_url_cb (GObject *object,
gpointer user_data)
{
FspSession* session = FSP_SESSION (object);
GError *error = NULL;
gchar *auth_url = fsp_session_get_auth_url_finish (session, res, &error);
g_autoptr(GError) error = NULL;
g_autofree gchar *auth_url = fsp_session_get_auth_url_finish (session, res, &error);
if (error != NULL)
{
g_print ("Error getting auth URL: %s\n", error->message);
g_error_free (error);
}
else
{
......@@ -734,19 +713,16 @@ get_auth_url_cb (GObject *object,
g_print ("\nEnter the verification code and press ENTER to continue: ");
if (fgets(buffer, 12, stdin))
{
gchar *verifier = NULL;
g_autofree gchar *verifier = NULL;
verifier = encode_uri (buffer);
/* Continue finishing the authorization */
g_print ("Finishing authorization...\n");
fsp_session_complete_auth (session, verifier, NULL, complete_auth_cb, NULL);
g_free (verifier);
}
else
g_print ("Authorization failed. Can't continue.\n");
g_free (auth_url);
}
}
......
......@@ -234,7 +234,7 @@ _parse_error_from_node (xmlNode *error_node,
FspError error = FSP_ERROR_UNKNOWN;
xmlChar *code_str = NULL;
xmlChar *msg = NULL;
gchar *error_msg = NULL;
g_autofree gchar *error_msg = NULL;
gint code;
GError *err = NULL;
......@@ -257,7 +257,6 @@ _parse_error_from_node (xmlNode *error_node,
xmlFree (code_str);
xmlFree (msg);
g_free (error_msg);
return err;
}
......@@ -1246,8 +1245,8 @@ fsp_parser_get_request_token (FspParser *self,
GError **error)
{
FspDataAuthToken *auth_token = NULL;
gchar *response_str = NULL;
gchar **response_array = NULL;
g_autofree gchar *response_str = NULL;
g_auto(GStrv) response_array = NULL;
gint i = 0;
g_return_val_if_fail (FSP_IS_PARSER (self), NULL);
......@@ -1257,7 +1256,6 @@ fsp_parser_get_request_token (FspParser *self,
auth_token = FSP_DATA_AUTH_TOKEN (fsp_data_new (FSP_AUTH_TOKEN));
response_str = g_strndup (buffer, buf_size);
response_array = g_strsplit (response_str, "&", -1);
g_free (response_str);
for (i = 0; response_array[i]; i++)
{
......@@ -1267,7 +1265,6 @@ fsp_parser_get_request_token (FspParser *self,
if (g_str_has_prefix (response_array[i], "oauth_token_secret="))
auth_token->token_secret = g_strdup (&response_array[i][19]);
}
g_strfreev (response_array);
/* Create the GError if needed*/
if (!auth_token->token || !auth_token->token_secret)
......@@ -1291,8 +1288,8 @@ fsp_parser_get_access_token (FspParser *self,
GError **error)
{
FspDataAuthToken *auth_token = NULL;
gchar *response_str = NULL;
gchar **response_array = NULL;
g_autofree gchar *response_str = NULL;
g_auto(GStrv) response_array = NULL;
gint i = 0;
g_return_val_if_fail (FSP_IS_PARSER (self), NULL);
......@@ -1302,7 +1299,6 @@ fsp_parser_get_access_token (FspParser *self,
auth_token = FSP_DATA_AUTH_TOKEN (fsp_data_new (FSP_AUTH_TOKEN));
response_str = g_strndup (buffer, buf_size);
response_array = g_strsplit (response_str, "&", -1);
g_free (response_str);
for (i = 0; response_array[i]; i++)
{
......@@ -1321,7 +1317,6 @@ fsp_parser_get_access_token (FspParser *self,
if (g_str_has_prefix (response_array[i], "oauth_token_secret="))
auth_token->token_secret = g_strdup (&response_array[i][19]);
}
g_strfreev (response_array);
/* Create the GError if needed*/
if (!auth_token->token || !auth_token->token_secret)
......
This diff is collapsed.
......@@ -47,15 +47,13 @@ static const gchar *website = "http://wiki.gnome.org/Apps/Frogr";
void
frogr_about_dialog_show (GtkWindow *parent)
{
GdkPixbuf *logo = NULL;
gchar *version = NULL;
gchar *icon_full_path = NULL;
g_autoptr(GdkPixbuf) logo = NULL;
g_autofree gchar *version = NULL;
g_autofree gchar *icon_full_path = NULL;
icon_full_path = g_strdup_printf ("%s/" ABOUT_DIALOG_ICON,
frogr_util_get_icons_dir ());
logo = gdk_pixbuf_new_from_file (icon_full_path, NULL);
g_free (icon_full_path);
version = g_strdup_printf ("%s~unreleased", PACKAGE_VERSION);
/* Show about dialog */
......@@ -72,7 +70,4 @@ frogr_about_dialog_show (GtkWindow *parent)
"translator-credits", _("translator-credits"),
"modal", TRUE,
NULL);
g_object_unref (logo);
g_free (version);
}
......@@ -70,7 +70,7 @@ _dialog_response_cb (GtkDialog *dialog, gint response, gpointer data)
if (response == GTK_RESPONSE_ACCEPT)
{
FrogrAddTagsDialog *self = NULL;
gchar *tags = NULL;
g_autofree gchar *tags = NULL;
self = FROGR_ADD_TAGS_DIALOG (dialog);
......@@ -98,9 +98,6 @@ _dialog_response_cb (GtkDialog *dialog, gint response, gpointer data)
model = frogr_controller_get_model (frogr_controller_get_instance ());
frogr_model_add_local_tags_from_string (model, tags);
}
/* Free */
g_free (tags);
}
/* Destroy the dialog */
......@@ -150,8 +147,7 @@ _frogr_add_tags_dialog_dispose (GObject *object)
if (dialog->pictures)
{
g_slist_foreach (dialog->pictures, (GFunc)g_object_unref, NULL);
g_slist_free (dialog->pictures);
g_slist_free_full (dialog->pictures, g_object_unref);
dialog->pictures = NULL;
}
......
......@@ -225,8 +225,8 @@ _tree_iter_compare_n_elements_func (GtkTreeModel *model,
GtkTreeIter *b,
gpointer data)
{
gchar *a_str = NULL;
gchar *b_str = NULL;
g_autofree gchar *a_str = NULL;
g_autofree gchar *b_str = NULL;
gint a_value = 0;
gint b_value = 0;
......@@ -238,9 +238,6 @@ _tree_iter_compare_n_elements_func (GtkTreeModel *model,
a_value = g_ascii_strtoll (a_str, NULL, 10);
b_value = g_ascii_strtoll (b_str, NULL, 10);
g_free (a_str);
g_free (b_str);
return (a_value - b_value);
}
......@@ -289,7 +286,7 @@ _fill_dialog_with_data (FrogrAddToGroupDialog *self)
gtk_tree_model_get_iter_first (self->treemodel, &iter);
do
{
FrogrGroup *group = NULL;
g_autoptr(FrogrGroup) group = NULL;
GSList *p_item = NULL;
gboolean do_check = TRUE;
......@@ -307,7 +304,6 @@ _fill_dialog_with_data (FrogrAddToGroupDialog *self)
break;
}
}
g_object_unref (group);
gtk_list_store_set (GTK_LIST_STORE (self->treemodel), &iter,
CHECKBOX_COL, do_check, -1);
......@@ -463,15 +459,13 @@ _frogr_add_to_group_dialog_dispose (GObject *object)
if (dialog->pictures)
{
g_slist_foreach (dialog->pictures, (GFunc)g_object_unref, NULL);
g_slist_free (dialog->pictures);
g_slist_free_full (dialog->pictures, g_object_unref);
dialog->pictures = NULL;
}
if (dialog->groups)
{
g_slist_foreach (dialog->groups, (GFunc)g_object_unref, NULL);
g_slist_free (dialog->groups);
g_slist_free_full (dialog->groups, g_object_unref);
dialog->groups = NULL;
}
......
......@@ -226,8 +226,8 @@ _tree_iter_compare_n_elements_func (GtkTreeModel *model,
GtkTreeIter *b,
gpointer data)
{
gchar *a_str = NULL;
gchar *b_str = NULL;
g_autofree gchar *a_str = NULL;
g_autofree gchar *b_str = NULL;
gint a_value = 0;
gint b_value = 0;
......@@ -239,9 +239,6 @@ _tree_iter_compare_n_elements_func (GtkTreeModel *model,
a_value = g_ascii_strtoll (a_str, NULL, 10);
b_value = g_ascii_strtoll (b_str, NULL, 10);
g_free (a_str);
g_free (b_str);
return (a_value - b_value);
}
......@@ -290,7 +287,7 @@ _fill_dialog_with_data (FrogrAddToSetDialog *self)
gtk_tree_model_get_iter_first (self->treemodel, &iter);
do
{
FrogrPhotoSet *set = NULL;
g_autoptr(FrogrPhotoSet) set = NULL;
GSList *p_item = NULL;
gboolean do_check = TRUE;
......@@ -308,7 +305,6 @@ _fill_dialog_with_data (FrogrAddToSetDialog *self)
break;
}
}
g_object_unref (set);
gtk_list_store_set (GTK_LIST_STORE (self->treemodel), &iter,
CHECKBOX_COL, do_check, -1);
......@@ -464,15 +460,13 @@ _frogr_add_to_set_dialog_dispose (GObject *object)
if (dialog->pictures)
{
g_slist_foreach (dialog->pictures, (GFunc)g_object_unref, NULL);
g_slist_free (dialog->pictures);
g_slist_free_full (dialog->pictures, g_object_unref);
dialog->pictures = NULL;
}
if (dialog->photosets)
{
g_slist_foreach (dialog->photosets, (GFunc)g_object_unref, NULL);
g_slist_free (dialog->photosets);
g_slist_free_full (dialog->photosets, g_object_unref);
dialog->photosets = NULL;
}
......
......@@ -50,7 +50,7 @@ static void
_ask_for_authorization (GtkWindow *parent)
{
GtkWidget *dialog = NULL;
gchar *title = NULL;
g_autofree gchar *title = NULL;
dialog = gtk_message_dialog_new (parent,
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
......@@ -62,7 +62,6 @@ _ask_for_authorization (GtkWindow *parent)
title = g_strdup_printf (_("Authorize %s"), APP_SHORTNAME);
gtk_window_set_title (GTK_WINDOW (dialog), title);
g_free (title);
g_signal_connect (G_OBJECT (dialog), "response",
G_CALLBACK (_ask_for_authorization_response_cb), NULL);
......@@ -144,7 +143,7 @@ _ask_for_auth_confirmation (GtkWindow *parent)
GtkWidget *vbox = NULL;
GtkWidget *ver_code_entry = NULL;
GtkWidget *label = NULL;
gchar *title = NULL;
g_autofree gchar *title = NULL;
title = g_strdup_printf (_("Authorize %s"), APP_SHORTNAME);
dialog = gtk_dialog_new_with_buttons (title,
......@@ -156,7 +155,6 @@ _ask_for_auth_confirmation (GtkWindow *parent)
GTK_RESPONSE_CLOSE,
NULL);
gtk_container_set_border_width (GTK_CONTAINER (dialog), 6);
g_free (title);
/* Fill action area */
content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
......@@ -203,7 +201,7 @@ _ask_for_auth_confirmation_response_cb (GtkDialog *dialog, gint response, gpoint
const gchar *vercode_part1 = NULL;
const gchar *vercode_part2 = NULL;
const gchar *vercode_part3 = NULL;
gchar *vercode_full = NULL;
g_autofree gchar *vercode_full = NULL;
vercode_part1 = _get_entry_code_for_dialog (dialog, "vercode-1");
vercode_part2 = _get_entry_code_for_dialog (dialog, "vercode-2");
......@@ -219,8 +217,6 @@ _ask_for_auth_confirmation_response_cb (GtkDialog *dialog, gint response, gpoint
}
else
frogr_util_show_error_dialog (GTK_WINDOW (dialog), _("Invalid verification code"));
g_free (vercode_full);
}
if (response == GTK_RESPONSE_CANCEL || valid)
......
......@@ -145,7 +145,7 @@ _find_account_by_username (FrogrConfig *self, const gchar *username)
static void
_load_settings (FrogrConfig *self)
{
gchar *xml_path = NULL;
g_autofree gchar *xml_path = NULL;
xmlNodePtr node = NULL;
xmlDocPtr xml = NULL;
......@@ -313,8 +313,6 @@ _load_settings (FrogrConfig *self)
if (xml)
xmlFreeDoc (xml);
g_free (xml_path);
}
static void
......@@ -499,7 +497,7 @@ _load_proxy_data_xml (FrogrConfig *self,
static void
_load_accounts (FrogrConfig *self)
{
gchar *xml_path = NULL;
g_autofree gchar *xml_path = NULL;
xmlNodePtr node = NULL;
xmlDocPtr xml = NULL;
......@@ -522,7 +520,7 @@ _load_accounts (FrogrConfig *self)
/* Node "account" found, stop searching */
if (!xmlStrcmp (node->name, (const xmlChar*) "account"))
{
FrogrAccount *account = frogr_account_new ();
g_autoptr(FrogrAccount) account = frogr_account_new ();
if (_load_account_xml (account, xml, node))
frogr_config_add_account (self, account);
......@@ -536,8 +534,6 @@ _load_accounts (FrogrConfig *self)
xmlSaveFormatFileEnc (xml_path, xml, "UTF-8", 1);
}
g_object_unref (account);
}
}
}
......@@ -553,8 +549,6 @@ _load_accounts (FrogrConfig *self)
if (xml)
xmlFreeDoc (xml);
g_free (xml_path);
}
static gboolean
......@@ -652,7 +646,7 @@ _save_settings (FrogrConfig *self)
xmlDocPtr xml = NULL;
xmlNodePtr root = NULL;
xmlNodePtr node = NULL;
gchar *xml_path = NULL;
g_autofree gchar *xml_path = NULL;
gboolean retval = TRUE;
g_return_val_if_fail (FROGR_IS_CONFIG (self), FALSE);
......@@ -714,7 +708,6 @@ _save_settings (FrogrConfig *self)
/* Free */
xmlFreeDoc (xml);
g_free (xml_path);
return retval;
}
......@@ -726,7 +719,7 @@ _save_accounts (FrogrConfig *self)
GSList *item = NULL;
xmlDocPtr xml = NULL;
xmlNodePtr root = NULL;
gchar *xml_path = NULL;
g_autofree gchar *xml_path = NULL;
gboolean retval = TRUE;
g_return_val_if_fail (FROGR_IS_CONFIG (self), FALSE);
......@@ -751,7 +744,6 @@ _save_accounts (FrogrConfig *self)
/* Free */
xmlFreeDoc (xml);
g_free (xml_path);
return retval;
}
......@@ -788,11 +780,10 @@ static xmlNodePtr
_xml_add_int_child (xmlNodePtr parent, const gchar *xml_name, gint value)
{
xmlNodePtr result = NULL;
gchar *int_str = NULL;
g_autofree gchar *int_str = NULL;
int_str = g_strdup_printf ("%d", value);
result = _xml_add_string_child (parent, xml_name, int_str);
g_free (int_str);
return result;
}
......@@ -801,11 +792,10 @@ static xmlNodePtr
_xml_add_bool_child (xmlNodePtr parent, const gchar *xml_name, gboolean value)
{
xmlNodePtr result = NULL;
gchar *bool_str = NULL;
g_autofree gchar *bool_str = NULL;
bool_str = g_strdup_printf ("%d", value ? 1 : 0);
result = _xml_add_string_child (parent, xml_name, bool_str);
g_free (bool_str);
return result;
}
......@@ -817,7 +807,7 @@ _xml_add_string_child (xmlNodePtr parent,
{
xmlNodePtr node = NULL;
xmlChar *enc = NULL;
gchar *actual_content = NULL;
g_autofree gchar *actual_content = NULL;
g_return_val_if_fail (parent != NULL, NULL);
g_return_val_if_fail (xml_name != NULL, NULL);
......@@ -832,7 +822,6 @@ _xml_add_string_child (xmlNodePtr parent,
xmlNodeSetContent (node, enc);
xmlFree (enc);
g_free (actual_content);
xmlAddChild (parent, node);
......@@ -875,8 +864,7 @@ _dispose (GObject *object)
if (config->accounts)
{
g_slist_foreach (config->accounts, (GFunc)g_object_unref, NULL);
g_slist_free (config->accounts);
g_slist_free_full (config->accounts, g_object_unref);
config->accounts = NULL;