diff options
49 files changed, 769 insertions, 802 deletions
diff --git a/client/as-builder.c b/client/as-builder.c index 5e9e2bf..efe6ded 100644 --- a/client/as-builder.c +++ b/client/as-builder.c @@ -43,13 +43,13 @@ static gboolean as_builder_search_path (GPtrArray *array, const gchar *path, GError **error) { const gchar *filename; - _cleanup_dir_close_ GDir *dir = NULL; + g_autoptr(GDir) dir = NULL; dir = g_dir_open (path, 0, error); if (dir == NULL) return FALSE; while ((filename = g_dir_read_name (dir)) != NULL) { - _cleanup_free_ gchar *tmp = NULL; + g_autofree gchar *tmp = NULL; tmp = g_build_filename (path, filename, NULL); if (g_file_test (tmp, G_FILE_TEST_IS_DIR)) { if (!as_builder_search_path (array, tmp, error)) @@ -71,9 +71,9 @@ as_builder_setup_ostree (AsbContext *ctx, const gchar *ostree_repo, GError **err GHashTableIter iter; gpointer key; gpointer value; - _cleanup_hashtable_unref_ GHashTable *refs = NULL; - _cleanup_object_unref_ GFile *file = NULL; - _cleanup_object_unref_ OstreeRepo *repo = NULL; + g_autoptr(GHashTable) refs = NULL; + g_autoptr(GFile) file = NULL; + g_autoptr(OstreeRepo) repo = NULL; /* load repo */ file = g_file_new_for_path (ostree_repo); @@ -85,11 +85,11 @@ as_builder_setup_ostree (AsbContext *ctx, const gchar *ostree_repo, GError **err g_hash_table_iter_init (&iter, refs); while (g_hash_table_iter_next (&iter, &key, &value)) { const gchar *refspec = key; - _cleanup_free_ gchar *remote = NULL; - _cleanup_free_ gchar *name = NULL; - _cleanup_free_ gchar *filename = NULL; - _cleanup_free_ gchar *ref = NULL; - _cleanup_object_unref_ AsbPackage *pkg = NULL; + g_autofree gchar *remote = NULL; + g_autofree gchar *name = NULL; + g_autofree gchar *filename = NULL; + g_autofree gchar *ref = NULL; + g_autoptr(AsbPackage) pkg = NULL; if (!ostree_parse_refspec (refspec, &remote, &ref, error)) return FALSE; @@ -140,21 +140,21 @@ main (int argc, char **argv) gint min_icon_size = 32; guint i; int retval = EXIT_SUCCESS; - _cleanup_dir_close_ GDir *dir = NULL; - _cleanup_error_free_ GError *error = NULL; - _cleanup_free_ gchar *basename = NULL; - _cleanup_free_ gchar *cache_dir = NULL; - _cleanup_free_ gchar *log_dir = NULL; - _cleanup_free_ gchar *icons_dir = NULL; - _cleanup_free_ gchar *old_metadata = NULL; - _cleanup_free_ gchar *origin = NULL; - _cleanup_free_ gchar *ostree_repo = NULL; - _cleanup_free_ gchar *output_dir = NULL; - _cleanup_free_ gchar *temp_dir = NULL; - _cleanup_free_ gchar **veto_ignore = NULL; - _cleanup_ptrarray_unref_ GPtrArray *packages = NULL; - _cleanup_strv_free_ gchar **packages_dirs = NULL; - _cleanup_timer_destroy_ GTimer *timer = NULL; + g_autoptr(GDir) dir = NULL; + g_autoptr(GError) error = NULL; + g_autofree gchar *basename = NULL; + g_autofree gchar *cache_dir = NULL; + g_autofree gchar *log_dir = NULL; + g_autofree gchar *icons_dir = NULL; + g_autofree gchar *old_metadata = NULL; + g_autofree gchar *origin = NULL; + g_autofree gchar *ostree_repo = NULL; + g_autofree gchar *output_dir = NULL; + g_autofree gchar *temp_dir = NULL; + g_autofree gchar **veto_ignore = NULL; + g_autoptr(GPtrArray) packages = NULL; + g_auto(GStrv) packages_dirs = NULL; + g_autoptr(GTimer) timer = NULL; const GOptionEntry options[] = { { "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, /* TRANSLATORS: command line option */ @@ -353,7 +353,7 @@ main (int argc, char **argv) if (argc == 1 && ostree_repo == NULL) { /* if the user launches the tool with no arguments */ if (packages_dirs == NULL) { - _cleanup_free_ gchar *tmp = NULL; + g_autofree gchar *tmp = NULL; tmp = g_option_context_get_help (option_context, TRUE, NULL); g_print ("%s", tmp); retval = EXIT_FAILURE; @@ -375,7 +375,7 @@ main (int argc, char **argv) g_print ("%s\n", _("Scanning packages...")); timer = g_timer_new (); for (i = 0; i < packages->len; i++) { - _cleanup_error_free_ GError *error_local = NULL; + g_autoptr(GError) error_local = NULL; filename = g_ptr_array_index (packages, i); diff --git a/client/as-util.c b/client/as-util.c index 0deca94..db02ec5 100644 --- a/client/as-util.c +++ b/client/as-util.c @@ -91,7 +91,7 @@ as_util_add (GPtrArray *array, { AsUtilItem *item; guint i; - _cleanup_strv_free_ gchar **names = NULL; + g_auto(GStrv) names = NULL; g_return_if_fail (name != NULL); g_return_if_fail (description != NULL); @@ -482,7 +482,7 @@ as_util_convert_appstream (GFile *file_input, gdouble new_version, GError **error) { - _cleanup_object_unref_ AsStore *store = NULL; + g_autoptr(AsStore) store = NULL; store = as_store_new (); if (!as_store_from_file (store, file_input, NULL, NULL, error)) @@ -512,8 +512,8 @@ as_util_convert (AsUtilPrivate *priv, gchar **values, GError **error) AsAppSourceKind input_kind; AsAppSourceKind output_kind; gdouble new_version; - _cleanup_object_unref_ GFile *file_input = NULL; - _cleanup_object_unref_ GFile *file_output = NULL; + g_autoptr(GFile) file_input = NULL; + g_autoptr(GFile) file_output = NULL; /* check args */ if (g_strv_length (values) != 3) { @@ -582,7 +582,7 @@ as_util_upgrade (AsUtilPrivate *priv, gchar **values, GError **error) /* process each file */ for (i = 0; values[i] != NULL; i++) { - _cleanup_object_unref_ GFile *file = NULL; + g_autoptr(GFile) file = NULL; AsAppSourceKind source_kind; source_kind = as_app_guess_source_kind (values[i]); switch (source_kind) { @@ -632,7 +632,7 @@ as_util_appdata_to_news (AsUtilPrivate *priv, gchar **values, GError **error) /* convert all the AppData files */ for (f = 0; values[f] != NULL; f++) { - _cleanup_object_unref_ AsApp *app = NULL; + g_autoptr(AsApp) app = NULL; _cleanup_string_free_ GString *str = NULL; /* add separator */ @@ -658,9 +658,9 @@ as_util_appdata_to_news (AsUtilPrivate *priv, gchar **values, GError **error) for (i = 0; i < releases->len; i++) { AsRelease *rel; const gchar *tmp; - _cleanup_free_ gchar *version = NULL; - _cleanup_free_ gchar *date = NULL; - _cleanup_date_time_unref_ GDateTime *dt = NULL; + g_autofree gchar *version = NULL; + g_autofree gchar *date = NULL; + g_autoptr(GDateTime) dt = NULL; rel = g_ptr_array_index (releases, i); @@ -681,7 +681,7 @@ as_util_appdata_to_news (AsUtilPrivate *priv, gchar **values, GError **error) /* print description */ tmp = as_release_get_description (rel, NULL); if (tmp != NULL) { - _cleanup_free_ gchar *md = NULL; + g_autofree gchar *md = NULL; md = as_markup_convert (tmp, AS_MARKUP_CONVERT_FORMAT_MARKDOWN, error); @@ -796,7 +796,7 @@ as_util_news_add_markup (GString *desc, const gchar *tag, const gchar *line) { guint i; guint indent = 0; - _cleanup_free_ gchar *escaped = NULL; + g_autofree gchar *escaped = NULL; /* empty line means do nothing */ if (line != NULL && line[0] == '\0') @@ -826,7 +826,7 @@ as_util_news_add_markup (GString *desc, const gchar *tag, const gchar *line) g_string_append_printf (desc, "<%s>\n", tag); } else { gchar *tmp; - _cleanup_strv_free_ gchar **lines = NULL; + g_auto(GStrv) lines = NULL; escaped = g_markup_escape_text (line, -1); tmp = g_strrstr (escaped, " ("); if (tmp != NULL) @@ -863,9 +863,9 @@ as_util_news_to_appdata_hdr (GString *desc, const gchar *txt, GError **error) guint i; const gchar *version = NULL; const gchar *release = NULL; - _cleanup_strv_free_ gchar **release_split = NULL; - _cleanup_date_time_unref_ GDateTime *dt = NULL; - _cleanup_strv_free_ gchar **lines = NULL; + g_auto(GStrv) release_split = NULL; + g_autoptr(GDateTime) dt = NULL; + g_auto(GStrv) lines = NULL; /* get info */ lines = g_strsplit (txt, "\n", -1); @@ -955,7 +955,7 @@ static gboolean as_util_news_to_appdata_para (GString *desc, const gchar *txt, GError **error) { guint i; - _cleanup_strv_free_ gchar **lines = NULL; + g_auto(GStrv) lines = NULL; lines = g_strsplit (txt, "\n", -1); for (i = 1; lines[i] != NULL; i++) { @@ -974,10 +974,10 @@ static gboolean as_util_news_to_appdata (AsUtilPrivate *priv, gchar **values, GError **error) { guint i; - _cleanup_free_ gchar *data = NULL; + g_autofree gchar *data = NULL; _cleanup_string_free_ GString *data_str = NULL; _cleanup_string_free_ GString *desc = NULL; - _cleanup_strv_free_ gchar **split = NULL; + g_auto(GStrv) split = NULL; /* check args */ if (g_strv_length (values) != 1) { @@ -1001,7 +1001,7 @@ as_util_news_to_appdata (AsUtilPrivate *priv, gchar **values, GError **error) desc = g_string_new (""); split = g_strsplit (data_str->str, "\n\n", -1); for (i = 0; split[i] != NULL; i++) { - _cleanup_strv_free_ gchar **lines = NULL; + g_auto(GStrv) lines = NULL; /* ignore empty sections */ if (split[i][0] == '\0') @@ -1081,13 +1081,13 @@ static gboolean as_util_appdata_from_desktop (AsUtilPrivate *priv, gchar **values, GError **error) { gchar *instr = NULL; - _cleanup_free_ gchar *id_new = NULL; - _cleanup_object_unref_ AsApp *app = NULL; - _cleanup_object_unref_ AsImage *im1 = NULL; - _cleanup_object_unref_ AsImage *im2 = NULL; - _cleanup_object_unref_ AsScreenshot *ss1 = NULL; - _cleanup_object_unref_ AsScreenshot *ss2 = NULL; - _cleanup_object_unref_ GFile *file = NULL; + g_autofree gchar *id_new = NULL; + g_autoptr(AsApp) app = NULL; + g_autoptr(AsImage) im1 = NULL; + g_autoptr(AsImage) im2 = NULL; + g_autoptr(AsScreenshot) ss1 = NULL; + g_autoptr(AsScreenshot) ss2 = NULL; + g_autoptr(GFile) file = NULL; /* check args */ if (g_strv_length (values) != 2) { @@ -1184,8 +1184,8 @@ as_util_appdata_from_desktop (AsUtilPrivate *priv, gchar **values, GError **erro static gboolean as_util_add_file_to_store (AsStore *store, const gchar *filename, GError **error) { - _cleanup_object_unref_ AsApp *app = NULL; - _cleanup_object_unref_ GFile *file_input = NULL; + g_autoptr(AsApp) app = NULL; + g_autoptr(GFile) file_input = NULL; switch (as_app_guess_source_kind (filename)) { case AS_APP_SOURCE_KIND_APPDATA: @@ -1221,7 +1221,7 @@ as_util_dump (AsUtilPrivate *priv, gchar **values, GError **error) { guint i; _cleanup_string_free_ GString *xml = NULL; - _cleanup_object_unref_ AsStore *store = NULL; + g_autoptr(AsStore) store = NULL; /* check args */ if (g_strv_length (values) < 1) { @@ -1267,7 +1267,7 @@ as_util_search (AsUtilPrivate *priv, gchar **values, GError **error) { GPtrArray *apps; guint i; - _cleanup_object_unref_ AsStore *store = NULL; + g_autoptr(AsStore) store = NULL; /* check args */ if (g_strv_length (values) < 1) { @@ -1323,9 +1323,9 @@ as_util_show_search_tokens (AsUtilPrivate *priv, gchar **values, GError **error) guint j; const gchar *tmp; guint *cnt; - _cleanup_hashtable_unref_ GHashTable *dict = NULL; - _cleanup_object_unref_ AsStore *store = NULL; - _cleanup_list_free_ GList *keys = NULL; + g_autoptr(GHashTable) dict = NULL; + g_autoptr(AsStore) store = NULL; + g_autoptr(GList) keys = NULL; /* load system database */ store = as_store_new (); @@ -1335,7 +1335,7 @@ as_util_show_search_tokens (AsUtilPrivate *priv, gchar **values, GError **error) apps = as_store_get_apps (store); for (i = 0; i < apps->len; i++) { AsApp *app; - _cleanup_ptrarray_unref_ GPtrArray *tokens = NULL; + g_autoptr(GPtrArray) tokens = NULL; app = g_ptr_array_index (apps, i); tokens = as_app_get_search_tokens (app); for (j = 0; j < tokens->len; j++) { @@ -1433,7 +1433,7 @@ static gboolean as_util_rmtree (const gchar *directory, GError **error) { const gchar *filename; - _cleanup_dir_close_ GDir *dir = NULL; + g_autoptr(GDir) dir = NULL; /* try to open */ dir = g_dir_open (directory, 0, error); @@ -1442,7 +1442,7 @@ as_util_rmtree (const gchar *directory, GError **error) /* find each */ while ((filename = g_dir_read_name (dir))) { - _cleanup_free_ gchar *src = NULL; + g_autofree gchar *src = NULL; src = g_build_filename (directory, filename, NULL); if (g_file_test (src, G_FILE_TEST_IS_DIR)) { if (!as_util_rmtree (src, error)) @@ -1492,12 +1492,12 @@ as_util_uninstall (AsUtilPrivate *priv, gchar **values, GError **error) /* remove XML file */ destdir = g_getenv ("DESTDIR"); for (i = 0; locations[i] != NULL; i++) { - _cleanup_free_ gchar *path_xml = NULL; + g_autofree gchar *path_xml = NULL; path_xml = g_strdup_printf ("%s%s/app-info/xmls/%s.xml.gz", destdir != NULL ? destdir : "", locations[i], values[0]); if (g_file_test (path_xml, G_FILE_TEST_EXISTS)) { - _cleanup_object_unref_ GFile *file = NULL; + g_autoptr(GFile) file = NULL; file = g_file_new_for_path (path_xml); if (!g_file_delete (file, NULL, error)) return FALSE; @@ -1506,7 +1506,7 @@ as_util_uninstall (AsUtilPrivate *priv, gchar **values, GError **error) /* remove icons */ for (i = 0; locations[i] != NULL; i++) { - _cleanup_free_ gchar *path_icons = NULL; + g_autofree gchar *path_icons = NULL; path_icons = g_strdup_printf ("%s%s/app-info/icons/%s", destdir != NULL ? destdir : "", locations[i], values[0]); @@ -2068,8 +2068,8 @@ as_util_status_html (AsUtilPrivate *priv, gchar **values, GError **error) AsUtilDistro distro = AS_UTIL_DISTRO_UNKNOWN; GPtrArray *apps = NULL; guint i; - _cleanup_object_unref_ AsStore *store = NULL; - _cleanup_object_unref_ GFile *file = NULL; + g_autoptr(AsStore) store = NULL; + g_autoptr(GFile) file = NULL; _cleanup_string_free_ GString *html = NULL; /* check args */ @@ -2287,7 +2287,7 @@ as_util_matrix_html_write_app (AsApp *app, GString *html, AsUtilDistro distro) if (arr == NULL || arr->len == 0) { as_util_matrix_html_write_item (NULL, AS_UTIL_PKG_STATE_OK, str, NULL); } else { - _cleanup_free_ gchar *tmp = NULL; + g_autofree gchar *tmp = NULL; tmp = as_util_status_html_join (arr); if (g_strstr_len (tmp, -1, "Dead upstream") != NULL) { as_util_matrix_html_write_item (&state_app, @@ -2348,7 +2348,7 @@ as_util_matrix_html (AsUtilPrivate *priv, gchar **values, GError **error) AsUtilDistro distro = AS_UTIL_DISTRO_UNKNOWN; GPtrArray *apps = NULL; guint i; - _cleanup_object_unref_ AsStore *store = NULL; + g_autoptr(AsStore) store = NULL; _cleanup_string_free_ GString *html = NULL; /* check args */ @@ -2364,7 +2364,7 @@ as_util_matrix_html (AsUtilPrivate *priv, gchar **values, GError **error) /* load file */ store = as_store_new (); for (i = 1; values[i] != NULL; i++) { - _cleanup_object_unref_ GFile *file = NULL; + g_autoptr(GFile) file = NULL; file = g_file_new_for_path (values[i]); if (!as_store_from_file (store, file, NULL, NULL, error)) return FALSE; @@ -2438,7 +2438,7 @@ as_util_status_csv_filter_func (AsApp *app, gchar **filters) AsIdKind id_kind = AS_ID_KIND_DESKTOP; for (i = 0; filters[i] != NULL; i++) { - _cleanup_strv_free_ gchar **split = NULL; + g_auto(GStrv) split = NULL; split = g_strsplit (filters[i], "=", 2); if (g_strv_length (split) != 2) continue; @@ -2469,8 +2469,8 @@ as_util_status_csv (AsUtilPrivate *priv, gchar **values, GError **error) GPtrArray *apps = NULL; const gchar *tmp; guint i; - _cleanup_object_unref_ AsStore *store = NULL; - _cleanup_object_unref_ GFile *file = NULL; + g_autoptr(AsStore) store = NULL; + g_autoptr(GFile) file = NULL; _cleanup_string_free_ GString *data = NULL; /* check args */ @@ -2493,7 +2493,7 @@ as_util_status_csv (AsUtilPrivate *priv, gchar **values, GError **error) /* write applications */ data = g_string_new ("id,pkgname,name,comment,description,url\n"); for (i = 0; i < apps->len; i++) { - _cleanup_free_ gchar *description = NULL; + g_autofree gchar *description = NULL; app = g_ptr_array_index (apps, i); /* process filters */ @@ -2530,8 +2530,8 @@ as_util_non_package_yaml (AsUtilPrivate *priv, gchar **values, GError **error) AsApp *app; GPtrArray *apps = NULL; guint i; - _cleanup_object_unref_ AsStore *store = NULL; - _cleanup_object_unref_ GFile *file = NULL; + g_autoptr(AsStore) store = NULL; + g_autoptr(GFile) file = NULL; _cleanup_string_free_ GString *yaml = NULL; /* check args */ @@ -2633,7 +2633,7 @@ as_util_validate_output_html (const gchar *filename, GPtrArray *probs) g_print ("<ul>\n"); for (i = 0; i < probs->len; i++) { AsProblem *problem; - _cleanup_free_ gchar *tmp = NULL; + g_autofree gchar *tmp = NULL; problem = g_ptr_array_index (probs, i); tmp = g_markup_escape_text (as_problem_get_message (problem), -1); g_print ("<li>"); @@ -2658,15 +2658,15 @@ as_util_validate_file (const gchar *filename, AsAppValidateFlags flags, GError **error) { - _cleanup_object_unref_ AsApp *app = NULL; - _cleanup_ptrarray_unref_ GPtrArray *probs = NULL; + g_autoptr(AsApp) app = NULL; + g_autoptr(GPtrArray) probs = NULL; /* is AppStream */ g_print ("%s: ", filename); if (as_app_guess_source_kind (filename) == AS_APP_SOURCE_KIND_APPSTREAM) { gboolean ret; - _cleanup_object_unref_ AsStore *store = NULL; - _cleanup_object_unref_ GFile *file = NULL; + g_autoptr(AsStore) store = NULL; + g_autoptr(GFile) file = NULL; file = g_file_new_for_path (filename); store = as_store_new (); ret = as_store_from_file (store, file, NULL, NULL, error); @@ -2789,8 +2789,8 @@ static gboolean as_util_check_root_app_icon (AsApp *app, GError **error) { AsIcon *icon_default; - _cleanup_free_ gchar *icon = NULL; - _cleanup_object_unref_ GdkPixbuf *pb = NULL; + g_autofree gchar *icon = NULL; + g_autoptr(GdkPixbuf) pb = NULL; /* nothing found */ icon_default = as_app_get_icon_default (app); @@ -2886,7 +2886,7 @@ as_util_app_log (AsApp *app, const gchar *fmt, ...) const gchar *id; guint i; va_list args; - _cleanup_free_ gchar *tmp = NULL; + g_autofree gchar *tmp = NULL; va_start (args, fmt); tmp = g_strdup_vprintf (fmt, args); @@ -2910,10 +2910,10 @@ as_util_mirror_screenshots_thumb (AsScreenshot *ss, AsImage *im_src, const gchar *output_dir, GError **error) { - _cleanup_free_ gchar *fn = NULL; - _cleanup_free_ gchar *size_str = NULL; - _cleanup_free_ gchar *url_tmp = NULL; - _cleanup_object_unref_ AsImage *im_tmp = NULL; + g_autofree gchar *fn = NULL; + g_autofree gchar *size_str = NULL; + g_autofree gchar *url_tmp = NULL; + g_autoptr(AsImage) im_tmp = NULL; /* only save the HiDPI screenshot if it's not padded */ if (scale > 1) { @@ -2965,10 +2965,10 @@ as_util_mirror_screenshots_app_file (AsApp *app, { AsImageAlphaFlags alpha_flags; guint i; - _cleanup_free_ gchar *basename = NULL; - _cleanup_free_ gchar *filename_no_path = NULL; - _cleanup_free_ gchar *url_src = NULL; - _cleanup_object_unref_ AsImage *im_src = NULL; + g_autofree gchar *basename = NULL; + g_autofree gchar *filename_no_path = NULL; + g_autofree gchar *url_src = NULL; + g_autoptr(AsImage) im_src = NULL; guint sizes[] = { AS_IMAGE_NORMAL_WIDTH, AS_IMAGE_NORMAL_HEIGHT, AS_IMAGE_THUMBNAIL_WIDTH, AS_IMAGE_THUMBNAIL_HEIGHT, AS_IMAGE_LARGE_WIDTH, AS_IMAGE_LARGE_HEIGHT, @@ -3066,16 +3066,16 @@ as_util_mirror_screenshots_app_url (AsUtilPrivate *priv, gboolean ret = TRUE; SoupStatus status; SoupURI *uri = NULL; - _cleanup_free_ gchar *basename = NULL; - _cleanup_free_ gchar *cache_filename = NULL; - _cleanup_object_unref_ AsImage *im = NULL; - _cleanup_object_unref_ AsScreenshot *ss = NULL; + g_autofree gchar *basename = NULL; + g_autofree gchar *cache_filename = NULL; + g_autoptr(AsImage) im = NULL; + g_autoptr(AsScreenshot) ss = NULL; _cleanup_object_unref_ SoupMessage *msg = NULL; - _cleanup_object_unref_ SoupSession *session = NULL; + g_autoptr(SoupSession) session = NULL; /* fonts screenshots are auto-generated */ if (as_app_get_id_kind (app) == AS_ID_KIND_FONT) { - _cleanup_free_ gchar *url_new = NULL; + g_autofree gchar *url_new = NULL; basename = g_path_get_basename (url); url_new = g_build_filename (mirror_uri, "source", basename, NULL); im = as_image_new (); @@ -3180,7 +3180,7 @@ as_util_mirror_screenshots_app (AsUtilPrivate *priv, const gchar *url; for (i = 0; i < urls->len; i++) { - _cleanup_error_free_ GError *error_local = NULL; + g_autoptr(GError) error_local = NULL; /* download URL or get from cache */ url = g_ptr_array_index (urls, i); @@ -3216,8 +3216,8 @@ as_util_mirror_screenshots (AsUtilPrivate *priv, gchar **values, GError **error) guint k; const gchar *cache_dir = "./cache/"; const gchar *output_dir = "./screenshots/"; - _cleanup_object_unref_ AsStore *store = NULL; - _cleanup_object_unref_ GFile *file = NULL; + g_autoptr(AsStore) store = NULL; + g_autoptr(GFile) file = NULL; guint sizes[] = { AS_IMAGE_NORMAL_WIDTH, AS_IMAGE_NORMAL_HEIGHT, AS_IMAGE_THUMBNAIL_WIDTH, AS_IMAGE_THUMBNAIL_HEIGHT, AS_IMAGE_LARGE_WIDTH, AS_IMAGE_LARGE_HEIGHT, @@ -3251,8 +3251,8 @@ as_util_mirror_screenshots (AsUtilPrivate *priv, gchar **values, GError **error) /* create the tree of screenshot directories */ for (j = 1; j <= 2; j++) { for (i = 0; sizes[i] != 0; i += 2) { - _cleanup_free_ gchar *size_str = NULL; - _cleanup_free_ gchar *fn = NULL; + g_autofree gchar *size_str = NULL; + g_autofree gchar *fn = NULL; size_str = g_strdup_printf ("%ix%i", sizes[i+0] * j, sizes[i+1] * j); @@ -3276,7 +3276,7 @@ as_util_mirror_screenshots (AsUtilPrivate *priv, gchar **values, GError **error) /* convert all the screenshots */ apps = as_store_get_apps (store); for (i = 0; i < apps->len; i++) { - _cleanup_ptrarray_unref_ GPtrArray *urls = NULL; + g_autoptr(GPtrArray) urls = NULL; /* get app */ app = g_ptr_array_index (apps, i); @@ -3332,8 +3332,8 @@ as_util_mirror_local_firmware (AsUtilPrivate *priv, gchar **values, GError **err GPtrArray *apps; guint i; guint j; - _cleanup_object_unref_ AsStore *store = NULL; - _cleanup_object_unref_ GFile *file = NULL; + g_autoptr(AsStore) store = NULL; + g_autoptr(GFile) file = NULL; /* check args */ if (g_strv_length (values) != 2) { @@ -3367,8 +3367,8 @@ as_util_mirror_local_firmware (AsUtilPrivate *priv, gchar **values, GError **err for (j = 0; j < releases->len; j++) { AsChecksum *csum; const gchar *tmp; - _cleanup_free_ gchar *loc = NULL; - _cleanup_free_ gchar *fn = NULL; + g_autofree gchar *loc = NULL; + g_autofree gchar *fn = NULL; rel = g_ptr_array_index (releases, j); /* get the release filename, but fall back to @@ -3411,8 +3411,8 @@ as_util_replace_screenshots (AsUtilPrivate *priv, gchar **values, GError **error { GPtrArray *screenshots; guint i; - _cleanup_object_unref_ AsApp *app = NULL; - _cleanup_object_unref_ GFile *file = NULL; + g_autoptr(AsApp) app = NULL; + g_autoptr(GFile) file = NULL; /* check args */ if (g_strv_length (values) < 2) { @@ -3433,8 +3433,8 @@ as_util_replace_screenshots (AsUtilPrivate *priv, gchar **values, GError **error screenshots = as_app_get_screenshots (app); g_ptr_array_set_size (screenshots, 0); for (i = 1; values[i] != NULL; i++) { - _cleanup_object_unref_ AsImage *im = NULL; - _cleanup_object_unref_ AsScreenshot *ss = NULL; + g_autoptr(AsImage) im = NULL; + g_autoptr(AsScreenshot) ss = NULL; im = as_image_new (); as_image_set_url (im, values[i]); as_image_set_kind (im, AS_IMAGE_KIND_SOURCE); @@ -3477,10 +3477,10 @@ as_util_compare (AsUtilPrivate *priv, gchar **values, GError **error) const gchar *id; const guint align = 50; guint i; - _cleanup_object_unref_ GFile *file_new = NULL; - _cleanup_object_unref_ GFile *file_old= NULL; - _cleanup_object_unref_ AsStore *store_new = NULL; - _cleanup_object_unref_ AsStore *store_old = NULL; + g_autoptr(GFile) file_new = NULL; + g_autoptr(GFile) file_old= NULL; + g_autoptr(AsStore) store_new = NULL; + g_autoptr(AsStore) store_old = NULL; /* check args */ if (g_strv_length (values) != 2) { @@ -3543,11 +3543,11 @@ as_util_incorporate (AsUtilPrivate *priv, gchar **values, GError **error) const guint align = 50; guint i; guint j; - _cleanup_object_unref_ AsStore *store = NULL; - _cleanup_object_unref_ AsStore *helper = NULL; - _cleanup_object_unref_ GFile *file_new = NULL; - _cleanup_object_unref_ GFile *file_old= NULL; - _cleanup_object_unref_ GFile *file_helper = NULL; + g_autoptr(AsStore) store = NULL; + g_autoptr(AsStore) helper = NULL; + g_autoptr(GFile) file_new = NULL; + g_autoptr(GFile) file_old= NULL; + g_autoptr(GFile) file_helper = NULL; /* check args */ if (g_strv_length (values) < 3) { @@ -3600,7 +3600,7 @@ as_util_incorporate (AsUtilPrivate *priv, gchar **values, GError **error) apps = as_store_get_apps (store); for (i = 0; i < apps->len; i++) { GPtrArray *pkgnames; - _cleanup_strv_free_ gchar **tmp = NULL; + g_auto(GStrv) tmp = NULL; app = g_ptr_array_index (apps, i); id = as_app_get_id (app); @@ -3661,8 +3661,8 @@ as_util_check_root (AsUtilPrivate *priv, gchar **values, GError **error) GPtrArray *apps; const gchar *tmp; guint i; - _cleanup_object_unref_ AsStore *store = NULL; - _cleanup_ptrarray_unref_ GPtrArray *problems = NULL; + g_autoptr(AsStore) store = NULL; + g_autoptr(GPtrArray) problems = NULL; /* check args */ if (g_strv_length (values) != 0) { @@ -3742,7 +3742,7 @@ main (int argc, char *argv[]) gboolean version = FALSE; GError *error = NULL; guint retval = 1; - _cleanup_free_ gchar *cmd_descriptions = NULL; + g_autofree gchar *cmd_descriptions = NULL; const GOptionEntry options[] = { { "nonet", '\0', 0, G_OPTION_ARG_NONE, &nonet, /* TRANSLATORS: this is the --nonet argument */ diff --git a/client/as-validate.c b/client/as-validate.c index 3d2eb5b..fe64a42 100644 --- a/client/as-validate.c +++ b/client/as-validate.c @@ -64,7 +64,7 @@ appdata_validate_format_html (const gchar *filename, GPtrArray *probs) g_print ("<p>%s did not validate:</p>\n", filename); g_print ("<ul>\n"); for (i = 0; i < probs->len; i++) { - _cleanup_free_ gchar *tmp = NULL; + g_autofree gchar *tmp = NULL; problem = g_ptr_array_index (probs, i); tmp = g_markup_escape_text (as_problem_get_message (problem), -1); g_print ("<li>"); @@ -95,7 +95,7 @@ appdata_validate_format_xml (const gchar *filename, GPtrArray *probs) if (probs->len > 0) { g_print (" <problems>\n"); for (i = 0; i < probs->len; i++) { - _cleanup_free_ gchar *tmp = NULL; + g_autofree gchar *tmp = NULL; problem = g_ptr_array_index (probs, i); tmp = g_markup_escape_text (as_problem_get_message (problem), -1); if (as_problem_get_line_number (problem) > 0) { @@ -161,9 +161,9 @@ appdata_validate_and_show_results (const gchar *filename_original, const gchar *tmp; gboolean ret; gint retval = EXIT_CODE_SUCCESS; - _cleanup_error_free_ GError *error = NULL; - _cleanup_object_unref_ AsApp *app = NULL; - _cleanup_ptrarray_unref_ GPtrArray *problems = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(AsApp) app = NULL; + g_autoptr(GPtrArray) problems = NULL; /* scan file for problems */ app = as_app_new (); @@ -220,8 +220,8 @@ main (int argc, char *argv[]) gint retval = EXIT_CODE_SUCCESS; gint retval_tmp; GOptionContext *context; - _cleanup_free_ gchar *filename = NULL; - _cleanup_free_ gchar *output_format = NULL; + g_autofree gchar *filename = NULL; + g_autofree gchar *output_format = NULL; const GOptionEntry options[] = { { "relax", 'r', 0, G_OPTION_ARG_NONE, &relax, /* TRANSLATORS: this is the --relax argument */ diff --git a/configure.ac b/configure.ac index 185cb2c..6242af8 100644 --- a/configure.ac +++ b/configure.ac @@ -129,7 +129,7 @@ AM_CONDITIONAL(HAVE_GPERF, [test x$GPERF != xno]) PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.44.0 gio-2.0 gobject-2.0 gthread-2.0 gio-unix-2.0 gmodule-2.0) PKG_CHECK_MODULES(LIBARCHIVE, libarchive) PKG_CHECK_MODULES(SOUP, libsoup-2.4 >= 2.24) -PKG_CHECK_MODULES(GDKPIXBUF, gdk-pixbuf-2.0 >= 2.14) +PKG_CHECK_MODULES(GDKPIXBUF, gdk-pixbuf-2.0 >= 2.31.5) # builder (default enabled) AC_ARG_ENABLE(builder, AS_HELP_STRING([--disable-builder],[Disable AppStream builder support]), enable_builder=$enableval) diff --git a/libappstream-builder/asb-app.c b/libappstream-builder/asb-app.c index d5d20d2..fe422f4 100644 --- a/libappstream-builder/asb-app.c +++ b/libappstream-builder/asb-app.c @@ -211,8 +211,8 @@ asb_app_save_resources (AsbApp *app, AsbAppSaveFlags save_flags, GError **error) icons = as_app_get_icons (AS_APP (app)); for (i = 0; icons != NULL && i < icons->len; i++) { const gchar *tmpdir; - _cleanup_free_ gchar *filename = NULL; - _cleanup_free_ gchar *size_str = NULL; + g_autofree gchar *filename = NULL; + g_autofree gchar *size_str = NULL; /* don't save some types of icons */ icon = g_ptr_array_index (icons, i); @@ -275,7 +275,7 @@ asb_app_new (AsbPackage *pkg, const gchar *id) break; case ASB_PACKAGE_KIND_BUNDLE: { - _cleanup_object_unref_ AsBundle *bundle = NULL; + g_autoptr(AsBundle) bundle = NULL; bundle = as_bundle_new (); as_bundle_set_id (bundle, asb_package_get_source (pkg)); as_bundle_set_kind (bundle, AS_BUNDLE_KIND_XDG_APP); diff --git a/libappstream-builder/asb-context.c b/libappstream-builder/asb-context.c index ae1b2eb..57972a6 100644 --- a/libappstream-builder/asb-context.c +++ b/libappstream-builder/asb-context.c @@ -466,7 +466,7 @@ asb_context_add_package (AsbContext *ctx, AsbPackage *pkg) gboolean asb_context_add_filename (AsbContext *ctx, const gchar *filename, GError **error) { - _cleanup_object_unref_ AsbPackage *pkg = NULL; + g_autoptr(AsbPackage) pkg = NULL; /* can find in existing metadata */ if (asb_context_find_in_cache (ctx, filename)) { @@ -541,9 +541,9 @@ gboolean asb_context_setup (AsbContext *ctx, GError **error) { AsbContextPrivate *priv = GET_PRIVATE (ctx); - _cleanup_free_ gchar *icons_dir = NULL; - _cleanup_free_ gchar *screenshot_dir1 = NULL; - _cleanup_free_ gchar *screenshot_dir2 = NULL; + g_autofree gchar *icons_dir = NULL; + g_autofree gchar *screenshot_dir1 = NULL; + g_autofree gchar *screenshot_dir2 = NULL; /* required stuff set */ if (priv->origin == NULL) { @@ -600,8 +600,8 @@ asb_context_setup (AsbContext *ctx, GError **error) if (!asb_utils_ensure_exists (priv->icons_dir, error)) return FALSE; if (priv->flags & ASB_CONTEXT_FLAG_HIDPI_ICONS) { - _cleanup_free_ gchar *icons_dir_hidpi = NULL; - _cleanup_free_ gchar *icons_dir_lodpi = NULL; + g_autofree gchar *icons_dir_hidpi = NULL; + g_autofree gchar *icons_dir_lodpi = NULL; icons_dir_lodpi = g_build_filename (priv->icons_dir, "64x64", NULL); if (!asb_utils_ensure_exists (icons_dir_lodpi, error)) return FALSE; @@ -612,7 +612,7 @@ asb_context_setup (AsbContext *ctx, GError **error) /* decompress the icons */ if (priv->old_metadata != NULL) { - _cleanup_free_ gchar *icons_fn = NULL; + g_autofree gchar *icons_fn = NULL; icons_fn = g_strdup_printf ("%s/%s-icons.tar.gz", priv->old_metadata, priv->basename); @@ -634,13 +634,13 @@ asb_context_setup (AsbContext *ctx, GError **error) /* add old metadata */ if (priv->old_metadata != NULL) { - _cleanup_free_ gchar *builder_id = NULL; - _cleanup_free_ gchar *fn_failed = NULL; - _cleanup_free_ gchar *fn_ignore = NULL; - _cleanup_free_ gchar *fn_old = NULL; - _cleanup_object_unref_ GFile *file_failed = NULL; - _cleanup_object_unref_ GFile *file_ignore = NULL; - _cleanup_object_unref_ GFile *file_old = NULL; + g_autofree gchar *builder_id = NULL; + g_autofree gchar *fn_failed = NULL; + g_autofree gchar *fn_ignore = NULL; + g_autofree gchar *fn_old = NULL; + g_autoptr(GFile) file_failed = NULL; + g_autoptr(GFile) file_ignore = NULL; + g_autoptr(GFile) file_old = NULL; builder_id = asb_utils_get_builder_id (); fn_old = g_strdup_printf ("%s/%s.xml.gz", @@ -706,7 +706,7 @@ static void asb_task_process_func (gpointer data, gpointer user_data) { AsbTask *task = (AsbTask *) data; - _cleanup_error_free_ GError *error = NULL; + g_autoptr(GError) error = NULL; /* just run the task */ if (!asb_task_process (task, &error)) @@ -722,7 +722,7 @@ asb_context_write_icons (AsbContext *ctx, GError **error) { AsbContextPrivate *priv = GET_PRIVATE (ctx); - _cleanup_free_ gchar *filename = NULL; + g_autofree gchar *filename = NULL; /* not enabled */ if (priv->flags & ASB_CONTEXT_FLAG_UNCOMPRESSED_ICONS) @@ -745,8 +745,8 @@ asb_context_write_screenshots (AsbContext *ctx, GError **error) { AsbContextPrivate *priv = GET_PRIVATE (ctx); - _cleanup_free_ gchar *filename = NULL; - _cleanup_free_ gchar *screenshot_dir = NULL; + g_autofree gchar *filename = NULL; + g_autofree gchar *screenshot_dir = NULL; /* not enabled */ if (priv->flags & ASB_CONTEXT_FLAG_UNCOMPRESSED_ICONS) @@ -770,9 +770,9 @@ asb_context_write_xml (AsbContext *ctx, GError **error) AsApp *app; AsbContextPrivate *priv = GET_PRIVATE (ctx); GList *l; - _cleanup_free_ gchar *filename = NULL; - _cleanup_object_unref_ AsStore *store = NULL; - _cleanup_object_unref_ GFile *file = NULL; + g_autofree gchar *filename = NULL; + g_autoptr(AsStore) store = NULL; + g_autoptr(GFile) file = NULL; /* convert any vetod applications into dummy components */ for (l = priv->apps; l != NULL; l = l->next) { @@ -796,7 +796,7 @@ asb_context_write_xml (AsbContext *ctx, GError **error) /* remove from the ignore list if the application was useful */ if (ASB_IS_APP (app)) { AsbPackage *pkg = asb_app_get_package (ASB_APP (app)); - _cleanup_free_ gchar *name_arch = NULL; + g_autofree gchar *name_arch = NULL; name_arch = g_strdup_printf ("%s.%s", asb_package_get_name (pkg), asb_package_get_arch (pkg)); @@ -813,7 +813,7 @@ asb_context_write_xml (AsbContext *ctx, GError **error) as_store_set_origin (store, priv->origin); as_store_set_api_version (store, priv->api_version); if (priv->flags & ASB_CONTEXT_FLAG_ADD_CACHE_ID) { - _cleanup_free_ gchar *builder_id = asb_utils_get_builder_id (); + g_autofree gchar *builder_id = asb_utils_get_builder_id (); as_store_set_builder_id (store, builder_id); } return as_store_to_file (store, @@ -886,7 +886,7 @@ asb_context_detect_pkgname_dups (AsbContext *ctx, GError **error) AsbContextPrivate *priv = GET_PRIVATE (ctx); GList *l; const gchar *pkgname; - _cleanup_hashtable_unref_ GHashTable *hash = NULL; + g_autoptr(GHashTable) hash = NULL; hash = g_hash_table_new (g_str_hash, g_str_equal); for (l = priv->apps; l != NULL; l = l->next) { @@ -921,7 +921,7 @@ asb_context_write_app_xml (AsbContext *ctx) /* log the XML in the log file */ for (l = priv->apps; l != NULL; l = l->next) { _cleanup_string_free_ GString *xml = NULL; - _cleanup_object_unref_ AsStore *store = NULL; + g_autoptr(AsStore) store = NULL; /* we have an open log file? */ if (!ASB_IS_APP (l->data)) @@ -976,7 +976,7 @@ asb_context_detect_missing_parents (AsbContext *ctx, GError **error) AsbContextPrivate *priv = GET_PRIVATE (ctx); GList *l; const gchar *tmp; - _cleanup_hashtable_unref_ GHashTable *hash = NULL; + g_autoptr(GHashTable) hash = NULL; /* add all desktop apps to the hash */ hash = g_hash_table_new (g_str_hash, g_str_equal); @@ -1030,9 +1030,9 @@ asb_context_write_xml_fail (AsbContext *ctx, GError **error) AsApp *app; AsbContextPrivate *priv = GET_PRIVATE (ctx); GList *l; - _cleanup_free_ gchar *basename_failed = NULL; - _cleanup_free_ gchar *filename = NULL; - _cleanup_object_unref_ GFile *file = NULL; + g_autofree gchar *basename_failed = NULL; + g_autofree gchar *filename = NULL; + g_autoptr(GFile) file = NULL; /* no need to create */ if ((priv->flags & ASB_CONTEXT_FLAG_INCLUDE_FAILED) == 0) @@ -1060,7 +1060,7 @@ asb_context_write_xml_fail (AsbContext *ctx, GError **error) as_store_set_origin (priv->store_failed, basename_failed); as_store_set_api_version (priv->store_failed, priv->api_version); if (priv->flags & ASB_CONTEXT_FLAG_ADD_CACHE_ID) { - _cleanup_free_ gchar *builder_id = asb_utils_get_builder_id (); + g_autofree gchar *builder_id = asb_utils_get_builder_id (); as_store_set_builder_id (priv->store_failed, builder_id); } return as_store_to_file (priv->store_failed, @@ -1078,9 +1078,9 @@ static gboolean asb_context_write_xml_ignore (AsbContext *ctx, GError **error) { AsbContextPrivate *priv = GET_PRIVATE (ctx); - _cleanup_free_ gchar *basename_cache = NULL; - _cleanup_free_ gchar *filename = NULL; - _cleanup_object_unref_ GFile *file = NULL; + g_autofree gchar *basename_cache = NULL; + g_autofree gchar *filename = NULL; + g_autoptr(GFile) file = NULL; /* no need to create */ if ((priv->flags & ASB_CONTEXT_FLAG_ADD_CACHE_ID) == 0) @@ -1096,7 +1096,7 @@ asb_context_write_xml_ignore (AsbContext *ctx, GError **error) as_store_set_origin (priv->store_ignore, basename_cache); as_store_set_api_version (priv->store_ignore, priv->api_version); if (priv->flags & ASB_CONTEXT_FLAG_ADD_CACHE_ID) { - _cleanup_free_ gchar *builder_id = asb_utils_get_builder_id (); + g_autofree gchar *builder_id = asb_utils_get_builder_id (); as_store_set_builder_id (priv->store_ignore, builder_id); } return as_store_to_file (priv->store_ignore, @@ -1118,7 +1118,7 @@ asb_context_disable_older_pkgs (AsbContext *ctx) AsbPackage *pkg; const gchar *key; guint i; - _cleanup_hashtable_unref_ GHashTable *newest = NULL; + g_autoptr(GHashTable) newest = NULL; newest = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_object_unref); @@ -1207,7 +1207,7 @@ asb_context_process (AsbContext *ctx, GError **error) GThreadPool *pool; gboolean ret; guint i; - _cleanup_ptrarray_unref_ GPtrArray *tasks = NULL; + g_autoptr(GPtrArray) tasks = NULL; /* only process the newest packages */ asb_context_disable_multiarch_pkgs (ctx); @@ -1340,10 +1340,10 @@ asb_context_find_in_cache (AsbContext *ctx, const gchar *filename) AsApp *app; AsbContextPrivate *priv = GET_PRIVATE (ctx); guint i; - _cleanup_free_ gchar *cache_id = NULL; - _cleanup_free_ gchar *builder_id = NULL; - _cleanup_ptrarray_unref_ GPtrArray *apps = NULL; - _cleanup_ptrarray_unref_ GPtrArray *apps_ignore = NULL; + g_autofree gchar *cache_id = NULL; + g_autofree gchar *builder_id = NULL; + g_autoptr(GPtrArray) apps = NULL; + g_autoptr(GPtrArray) apps_ignore = NULL; /* the package was successfully parsed last time */ cache_id = asb_utils_get_cache_id_for_filename (filename); @@ -1420,9 +1420,9 @@ asb_context_add_app_ignore (AsbContext *ctx, AsbPackage *pkg) { AsApp *app_tmp; AsbContextPrivate *priv = GET_PRIVATE (ctx); - _cleanup_free_ gchar *name_arch = NULL; - _cleanup_object_unref_ AsApp *app = NULL; - _cleanup_ptrarray_unref_ GPtrArray *apps = NULL; + g_autofree gchar *name_arch = NULL; + g_autoptr(AsApp) app = NULL; + g_autoptr(GPtrArray) apps = NULL; /* only do this when we are using a cache-id */ if ((priv->flags & ASB_CONTEXT_FLAG_ADD_CACHE_ID) == 0) diff --git a/libappstream-builder/asb-package-alpm.c b/libappstream-builder/asb-package-alpm.c index ae955c0..160eb53 100644 --- a/libappstream-builder/asb-package-alpm.c +++ b/libappstream-builder/asb-package-alpm.c @@ -122,7 +122,7 @@ asb_package_alpm_ensure_version (AsbPackage *pkg, GError **error) AsbPackageAlpm *pkg_alpm = ASB_PACKAGE_ALPM (pkg); AsbPackageAlpmPrivate *priv = GET_PRIVATE (pkg_alpm); - gchar _cleanup_strv_free_ **split = NULL; + g_auto(GStrv) split = NULL; split = g_strsplit (alpm_pkg_get_version (priv->package), ":-", 3); diff --git a/libappstream-builder/asb-package-cab.c b/libappstream-builder/asb-package-cab.c index e450291..26b320a 100644 --- a/libappstream-builder/asb-package-cab.c +++ b/libappstream-builder/asb-package-cab.c @@ -50,7 +50,7 @@ asb_package_cab_init (AsbPackageCab *pkg) static gboolean asb_package_cab_ensure_simple (AsbPackage *pkg, GError **error) { - _cleanup_free_ gchar *basename; + g_autofree gchar *basename; gchar *tmp; /* get basename minus the .cab extension */ @@ -82,9 +82,9 @@ asb_package_cab_ensure_filelists (AsbPackage *pkg, GError **error) { const gchar *argv[4] = { "gcab", "--list", "fn", NULL }; guint i; - _cleanup_free_ gchar *output = NULL; - _cleanup_ptrarray_unref_ GPtrArray *files = NULL; - _cleanup_strv_free_ gchar **lines = NULL; + g_autofree gchar *output = NULL; + g_autoptr(GPtrArray) files = NULL; + g_auto(GStrv) lines = NULL; /* spawn sync */ argv[2] = asb_package_get_filename (pkg); diff --git a/libappstream-builder/asb-package-deb.c b/libappstream-builder/asb-package-deb.c index 3b2f516..4565d3b 100644 --- a/libappstream-builder/asb-package-deb.c +++ b/libappstream-builder/asb-package-deb.c @@ -55,8 +55,8 @@ asb_package_deb_ensure_simple (AsbPackage *pkg, GError **error) gchar **vr; guint i; guint j; - _cleanup_free_ gchar *output = NULL; - _cleanup_strv_free_ gchar **lines = NULL; + g_autofree gchar *output = NULL; + g_auto(GStrv) lines = NULL; /* spawn sync */ argv[2] = asb_package_get_filename (pkg); @@ -115,9 +115,9 @@ asb_package_deb_ensure_filelists (AsbPackage *pkg, GError **error) const gchar *argv[4] = { "dpkg", "--contents", "fn", NULL }; const gchar *fn; guint i; - _cleanup_free_ gchar *output = NULL; - _cleanup_ptrarray_unref_ GPtrArray *files = NULL; - _cleanup_strv_free_ gchar **lines = NULL; + g_autofree gchar *output = NULL; + g_autoptr(GPtrArray) files = NULL; + g_auto(GStrv) lines = NULL; /* spawn sync */ argv[2] = asb_package_get_filename (pkg); @@ -184,7 +184,7 @@ asb_package_deb_explode (AsbPackage *pkg, /* then decompress the data file */ for (i = 0; data_names[i] != NULL; i++) { - _cleanup_free_ gchar *data_fn = NULL; + g_autofree gchar *data_fn = NULL; data_fn = g_build_filename (dir, data_names[i], NULL); if (g_file_test (data_fn, G_FILE_TEST_EXISTS)) { if (!asb_utils_explode (data_fn, dir, glob, error)) diff --git a/libappstream-builder/asb-package-ostree.c b/libappstream-builder/asb-package-ostree.c index 6aaf0b7..8f70bb9 100644 --- a/libappstream-builder/asb-package-ostree.c +++ b/libappstream-builder/asb-package-ostree.c @@ -87,7 +87,7 @@ asb_package_ostree_open (AsbPackage *pkg, const gchar *filename, GError **error) { AsbPackageOstree *pkg_ostree = ASB_PACKAGE_OSTREE (pkg); AsbPackageOstreePrivate *priv = GET_PRIVATE (pkg_ostree); - _cleanup_object_unref_ GFile *file = NULL; + g_autoptr(GFile) file = NULL; /* create the OstreeRepo */ file = g_file_new_for_path (priv->repodir); @@ -102,7 +102,7 @@ asb_package_ostree_open (AsbPackage *pkg, const gchar *filename, GError **error) static gboolean asb_package_ostree_build_filelist (GPtrArray *array, GFile *file, GError **error) { - _cleanup_object_unref_ GFileEnumerator *enumerator = NULL; + g_autoptr(GFileEnumerator) enumerator = NULL; /* iter on children */ enumerator = g_file_enumerate_children (file, "standard::*", @@ -111,8 +111,8 @@ asb_package_ostree_build_filelist (GPtrArray *array, GFile *file, GError **error if (enumerator == NULL) return FALSE; do { - _cleanup_free_ gchar *path = NULL; - _cleanup_object_unref_ GFileInfo *info = NULL; + g_autofree gchar *path = NULL; + g_autoptr(GFileInfo) info = NULL; info = g_file_enumerator_next_file (enumerator, NULL, error); if (info == NULL) { @@ -125,7 +125,7 @@ asb_package_ostree_build_filelist (GPtrArray *array, GFile *file, GError **error path = g_file_get_path (file); g_ptr_array_add (array, g_build_filename (path, g_file_info_get_name (info), NULL)); if (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY) { - _cleanup_object_unref_ GFile *child = NULL; + g_autoptr(GFile) child = NULL; child = g_file_get_child (g_file_enumerator_get_container (enumerator), g_file_info_get_name (info)); if (!asb_package_ostree_build_filelist (array, child, error)) @@ -144,8 +144,8 @@ asb_package_ostree_ensure_files (AsbPackage *pkg, GError **error) AsbPackageOstree *pkg_ostree = ASB_PACKAGE_OSTREE (pkg); AsbPackageOstreePrivate *priv = GET_PRIVATE (pkg_ostree); const gchar *rev; - _cleanup_object_unref_ GFile *root = NULL; - _cleanup_ptrarray_unref_ GPtrArray *array = NULL; + g_autoptr(GFile) root = NULL; + g_autoptr(GPtrArray) array = NULL; /* get the filelist */ if (!ostree_repo_open (priv->repo, NULL, error)) @@ -171,7 +171,7 @@ asb_package_ostree_ensure_files (AsbPackage *pkg, GError **error) static gboolean asb_package_ostree_ensure_nevra (AsbPackage *pkg, GError **error) { - _cleanup_strv_free_ gchar **split = NULL; + g_auto(GStrv) split = NULL; /* split up 'app/org.gnome.GEdit/x86_64/master' */ split = g_strsplit (asb_package_get_source (pkg), "/", -1); @@ -231,10 +231,10 @@ asb_package_ostree_explode (AsbPackage *pkg, const gchar *dir, AsbPackageOstree *pkg_ostree = ASB_PACKAGE_OSTREE (pkg); AsbPackageOstreePrivate *priv = GET_PRIVATE (pkg_ostree); const gchar *commit; - _cleanup_free_ gchar *resolved_commit = NULL; - _cleanup_object_unref_ GFileInfo *file_info = NULL; - _cleanup_object_unref_ GFile *root = NULL; - _cleanup_object_unref_ GFile *target = NULL; + g_autofree gchar *resolved_commit = NULL; + g_autoptr(GFileInfo) file_info = NULL; + g_autoptr(GFile) root = NULL; + g_autoptr(GFile) target = NULL; /* extract root */ commit = asb_package_get_source (pkg); diff --git a/libappstream-builder/asb-package-rpm.c b/libappstream-builder/asb-package-rpm.c index 9df3811..0703ae1 100644 --- a/libappstream-builder/asb-package-rpm.c +++ b/libappstream-builder/asb-package-rpm.c @@ -80,8 +80,8 @@ asb_package_rpm_set_license (AsbPackage *pkg, const gchar *license) { guint i; guint j; - _cleanup_free_ gchar *new = NULL; - _cleanup_strv_free_ gchar **tokens = NULL; + g_autofree gchar *new = NULL; + g_auto(GStrv) tokens = NULL; struct { const gchar *fedora; const gchar *spdx; @@ -203,7 +203,7 @@ static void asb_package_rpm_set_source (AsbPackage *pkg, const gchar *source) { gchar *tmp; - _cleanup_free_ gchar *srcrpm = NULL; + g_autofree gchar *srcrpm = NULL; /* this isn't supposed to happen */ if (source == NULL) { @@ -333,7 +333,7 @@ asb_package_rpm_add_release (AsbPackage *pkg, const gchar *version; gchar *tmp; gchar *vr; - _cleanup_free_ gchar *name_dup = NULL; + g_autofree gchar *name_dup = NULL; /* get last string chunk */ name_dup = g_strchomp (g_strdup (name)); @@ -440,7 +440,7 @@ asb_package_rpm_ensure_deps (AsbPackage *pkg, GError **error) goto out; } while (rpmtdNext (td) != -1) { - _cleanup_free_ gchar *dep_no_qual = NULL; + g_autofree gchar *dep_no_qual = NULL; dep = rpmtdGetString (td); if (g_str_has_prefix (dep, "rpmlib")) continue; @@ -470,9 +470,9 @@ asb_package_rpm_ensure_filelists (AsbPackage *pkg, GError **error) gint rc; guint i; rpmtd td[3] = { NULL, NULL, NULL }; - _cleanup_free_ const gchar **dirnames = NULL; - _cleanup_free_ gint32 *dirindex = NULL; - _cleanup_strv_free_ gchar **filelist = NULL; + g_autofree const gchar **dirnames = NULL; + g_autofree gint32 *dirindex = NULL; + g_auto(GStrv) filelist = NULL; /* is a virtual package with no files */ if (!headerIsEntry (priv->h, RPMTAG_DIRINDEXES)) diff --git a/libappstream-builder/asb-package.c b/libappstream-builder/asb-package.c index 8c94250..8cc2c18 100644 --- a/libappstream-builder/asb-package.c +++ b/libappstream-builder/asb-package.c @@ -194,7 +194,7 @@ asb_package_log (AsbPackage *pkg, AsbPackagePrivate *priv = GET_PRIVATE (pkg); va_list args; gdouble now; - _cleanup_free_ gchar *tmp = NULL; + g_autofree gchar *tmp = NULL; g_mutex_lock (&priv->mutex_log); @@ -245,8 +245,8 @@ gboolean asb_package_log_flush (AsbPackage *pkg, GError **error) { AsbPackagePrivate *priv = GET_PRIVATE (pkg); - _cleanup_free_ gchar *logfile = NULL; - _cleanup_free_ gchar *logdir_char = NULL; + g_autofree gchar *logfile = NULL; + g_autofree gchar *logdir_char = NULL; /* needs no update */ if (priv->log_written_len == priv->log->len) @@ -818,7 +818,7 @@ static void asb_package_guess_from_filename (AsbPackage *pkg) { AsbPackagePrivate *priv = GET_PRIVATE (pkg); - _cleanup_free_ gchar *tmp = NULL; + g_autofree gchar *tmp = NULL; gchar *at; /* remove .rpm extension */ diff --git a/libappstream-builder/asb-plugin-loader.c b/libappstream-builder/asb-plugin-loader.c index 3a8a95d..b611a34 100644 --- a/libappstream-builder/asb-plugin-loader.c +++ b/libappstream-builder/asb-plugin-loader.c @@ -277,7 +277,7 @@ asb_plugin_loader_merge (AsbPluginLoader *plugin_loader, GList *apps) const gchar *tmp; gboolean ret; guint i; - _cleanup_hashtable_unref_ GHashTable *hash = NULL; + g_autoptr(GHashTable) hash = NULL; /* run each plugin */ for (i = 0; i < priv->plugins->len; i++) { @@ -437,7 +437,7 @@ asb_plugin_loader_setup (AsbPluginLoader *plugin_loader, GError **error) { AsbPluginLoaderPrivate *priv = GET_PRIVATE (plugin_loader); const gchar *filename_tmp; - _cleanup_dir_close_ GDir *dir = NULL; + g_autoptr(GDir) dir = NULL; /* never set */ if (priv->plugin_dir == NULL) @@ -451,7 +451,7 @@ asb_plugin_loader_setup (AsbPluginLoader *plugin_loader, GError **error) /* try to open each plugin */ g_debug ("searching for plugins in %s", priv->plugin_dir); do { - _cleanup_free_ gchar *filename_plugin = NULL; + g_autofree gchar *filename_plugin = NULL; filename_tmp = g_dir_read_name (dir); if (filename_tmp == NULL) break; diff --git a/libappstream-builder/asb-plugin.c b/libappstream-builder/asb-plugin.c index a8654f7..3a8fb99 100644 --- a/libappstream-builder/asb-plugin.c +++ b/libappstream-builder/asb-plugin.c @@ -104,7 +104,7 @@ asb_plugin_add_glob (GPtrArray *array, const gchar *glob) { /* handle bundles automatically */ if (g_str_has_prefix (glob, "/usr/")) { - _cleanup_free_ gchar *glob_bundle = NULL; + g_autofree gchar *glob_bundle = NULL; glob_bundle = g_strdup_printf ("/files/%s", glob + 5); g_ptr_array_add (array, asb_glob_value_new (glob_bundle, "")); } @@ -125,7 +125,7 @@ asb_plugin_match_glob (const gchar *glob, const gchar *value) { /* handle bundles automatically */ if (g_str_has_prefix (glob, "/usr/")) { - _cleanup_free_ gchar *glob_bundle = NULL; + g_autofree gchar *glob_bundle = NULL; glob_bundle = g_strdup_printf ("/files/%s", glob + 5); if (fnmatch (glob_bundle, value, 0) == 0) return TRUE; diff --git a/libappstream-builder/asb-self-test.c b/libappstream-builder/asb-self-test.c index 7eb38ad..262395f 100644 --- a/libappstream-builder/asb-self-test.c +++ b/libappstream-builder/asb-self-test.c @@ -44,7 +44,7 @@ static gchar * asb_test_get_filename (const gchar *filename) { _cleanup_free_libc_ gchar *tmp = NULL; - _cleanup_free_ gchar *path = NULL; + g_autofree gchar *path = NULL; /* try the source then the destdir */ path = g_build_filename (TESTDIRSRC, filename, NULL); @@ -65,7 +65,7 @@ asb_test_get_filename (const gchar *filename) static gboolean asb_test_compare_lines (const gchar *txt1, const gchar *txt2, GError **error) { - _cleanup_free_ gchar *output = NULL; + g_autofree gchar *output = NULL; /* exactly the same */ if (g_strcmp0 (txt1, txt2) == 0) @@ -95,9 +95,9 @@ asb_test_package_rpm_func (void) GPtrArray *releases; gboolean ret; gchar *tmp; - _cleanup_free_ gchar *filename = NULL; - _cleanup_object_unref_ AsbPackage *pkg = NULL; - _cleanup_ptrarray_unref_ GPtrArray *glob = NULL; + g_autofree gchar *filename = NULL; + g_autoptr(AsbPackage) pkg = NULL; + g_autoptr(GPtrArray) glob = NULL; /* open file */ filename = asb_test_get_filename ("test-0.1-1.fc21.noarch.rpm"); @@ -211,7 +211,7 @@ asb_test_package_rpm_func (void) static void asb_test_package_func (void) { - _cleanup_object_unref_ AsbPackage *pkg = NULL; + g_autoptr(AsbPackage) pkg = NULL; pkg = asb_package_new (); asb_package_set_filename (pkg, "/tmp/gambit-c-doc-4.7.3-2.fc22.noarch.rpm"); g_assert_cmpstr (asb_package_get_nevra (pkg), ==, "gambit-c-doc-4.7.3-2.fc22.noarch"); @@ -223,7 +223,7 @@ asb_test_package_func (void) static void asb_test_utils_glob_func (void) { - _cleanup_ptrarray_unref_ GPtrArray *array = NULL; + g_autoptr(GPtrArray) array = NULL; array = asb_glob_value_array_new (); g_ptr_array_add (array, asb_glob_value_new ("*.desktop", "DESKTOP")); @@ -254,8 +254,8 @@ asb_test_plugin_loader_func (void) GError *error = NULL; GPtrArray *plugins; gboolean ret; - _cleanup_object_unref_ AsbContext *ctx = NULL; - _cleanup_ptrarray_unref_ GPtrArray *globs = NULL; + g_autoptr(AsbContext) ctx = NULL; + g_autoptr(GPtrArray) globs = NULL; /* set up loader */ ctx = asb_context_new (); @@ -305,13 +305,13 @@ asb_test_context_test_func (AsbTestContextMode mode) const gchar *expected_xml; gboolean ret; guint i; - _cleanup_object_unref_ AsbContext *ctx = NULL; - _cleanup_object_unref_ AsStore *store_failed = NULL; - _cleanup_object_unref_ AsStore *store_ignore = NULL; - _cleanup_object_unref_ AsStore *store = NULL; - _cleanup_object_unref_ GFile *file_failed = NULL; - _cleanup_object_unref_ GFile *file_ignore = NULL; - _cleanup_object_unref_ GFile *file = NULL; + g_autoptr(AsbContext) ctx = NULL; + g_autoptr(AsStore) store_failed = NULL; + g_autoptr(AsStore) store_ignore = NULL; + g_autoptr(AsStore) store = NULL; + g_autoptr(GFile) file_failed = NULL; + g_autoptr(GFile) file_ignore = NULL; + g_autoptr(GFile) file = NULL; _cleanup_string_free_ GString *xml = NULL; _cleanup_string_free_ GString *xml_failed = NULL; _cleanup_string_free_ GString *xml_ignore = NULL; @@ -348,7 +348,7 @@ asb_test_context_test_func (AsbTestContextMode mode) break; case ASB_TEST_CONTEXT_MODE_WITH_OLD_CACHE: { - _cleanup_free_ gchar *old_cache_dir = NULL; + g_autofree gchar *old_cache_dir = NULL; old_cache_dir = asb_test_get_filename ("."); asb_context_set_old_metadata (ctx, old_cache_dir); } @@ -366,7 +366,7 @@ asb_test_context_test_func (AsbTestContextMode mode) /* add packages */ for (i = 0; filenames[i] != NULL; i++) { - _cleanup_free_ gchar *filename = NULL; + g_autofree gchar *filename = NULL; filename = asb_test_get_filename (filenames[i]); if (filename == NULL) g_warning ("%s not found", filenames[i]); @@ -857,10 +857,10 @@ asb_test_firmware_func (void) const gchar *expected_xml; gboolean ret; guint i; - _cleanup_error_free_ GError *error = NULL; - _cleanup_object_unref_ AsbContext *ctx = NULL; - _cleanup_object_unref_ AsStore *store = NULL; - _cleanup_object_unref_ GFile *file = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(AsbContext) ctx = NULL; + g_autoptr(AsStore) store = NULL; + g_autoptr(GFile) file = NULL; _cleanup_string_free_ GString *xml = NULL; const gchar *filenames[] = { "colorhug-als-2.0.1.cab", @@ -887,7 +887,7 @@ asb_test_firmware_func (void) /* add packages */ for (i = 0; filenames[i] != NULL; i++) { - _cleanup_free_ gchar *filename = NULL; + g_autofree gchar *filename = NULL; filename = asb_test_get_filename (filenames[i]); if (filename == NULL) g_warning ("%s not found", filenames[i]); diff --git a/libappstream-builder/asb-task.c b/libappstream-builder/asb-task.c index 1fb3e7a..061d223 100644 --- a/libappstream-builder/asb-task.c +++ b/libappstream-builder/asb-task.c @@ -158,9 +158,9 @@ asb_task_explode_extra_packages (AsbTask *task, GError **error) const gchar *ignore[] = { "rtld", NULL }; const gchar *tmp; guint i; - _cleanup_hashtable_unref_ GHashTable *hash = NULL; - _cleanup_ptrarray_unref_ GPtrArray *array = NULL; - _cleanup_ptrarray_unref_ GPtrArray *icon_themes = NULL; + g_autoptr(GHashTable) hash = NULL; + g_autoptr(GPtrArray) array = NULL; + g_autoptr(GPtrArray) icon_themes = NULL; /* anything the package requires */ hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); @@ -240,8 +240,8 @@ asb_task_process (AsbTask *task, GError **error_not_used) gchar *tmp; guint i; guint nr_added = 0; - _cleanup_error_free_ GError *error = NULL; - _cleanup_free_ gchar *basename = NULL; + g_autoptr(GError) error = NULL; + g_autofree gchar *basename = NULL; /* reset the profile timer */ asb_package_log_start (priv->pkg); diff --git a/libappstream-builder/asb-utils.c b/libappstream-builder/asb-utils.c index ca90e62..a6b70bb 100644 --- a/libappstream-builder/asb-utils.c +++ b/libappstream-builder/asb-utils.c @@ -144,7 +144,7 @@ gboolean asb_utils_ensure_exists_and_empty (const gchar *directory, GError **error) { const gchar *filename; - _cleanup_dir_close_ GDir *dir = NULL; + g_autoptr(GDir) dir = NULL; /* does directory exist */ if (!asb_utils_ensure_exists (directory, error)) @@ -157,7 +157,7 @@ asb_utils_ensure_exists_and_empty (const gchar *directory, GError **error) /* find each */ while ((filename = g_dir_read_name (dir))) { - _cleanup_free_ gchar *src = NULL; + g_autofree gchar *src = NULL; src = g_build_filename (directory, filename, NULL); if (g_file_test (src, G_FILE_TEST_IS_DIR)) { if (!asb_utils_rmtree (src, error)) @@ -235,9 +235,9 @@ asb_utils_explode_file (struct archive_entry *entry, const gchar *dir) { const gchar *tmp; guint symlink_depth; - _cleanup_free_ gchar *back_up = NULL; - _cleanup_free_ gchar *path = NULL; - _cleanup_free_ gchar *buf = NULL; + g_autofree gchar *back_up = NULL; + g_autofree gchar *path = NULL; + g_autofree gchar *buf = NULL; /* no output file */ if (archive_entry_pathname (entry) == NULL) @@ -252,8 +252,8 @@ asb_utils_explode_file (struct archive_entry *entry, const gchar *dir) /* update hardlinks */ tmp = archive_entry_hardlink (entry); if (tmp != NULL) { - _cleanup_free_ gchar *buf_link = NULL; - _cleanup_free_ gchar *path_link = NULL; + g_autofree gchar *buf_link = NULL; + g_autofree gchar *path_link = NULL; path_link = asb_utils_sanitise_path (tmp); buf_link = g_build_filename (dir, path_link, NULL); if (!g_file_test (buf_link, G_FILE_TEST_EXISTS)) { @@ -266,7 +266,7 @@ asb_utils_explode_file (struct archive_entry *entry, const gchar *dir) /* update symlinks */ tmp = archive_entry_symlink (entry); if (tmp != NULL) { - _cleanup_free_ gchar *buf_link = NULL; + g_autofree gchar *buf_link = NULL; symlink_depth = asb_utils_count_directories_deep (path) - 1; back_up = asb_utils_get_back_to_root (symlink_depth); if (tmp[0] == '/') @@ -303,7 +303,7 @@ asb_utils_explode (const gchar *filename, struct archive *arch = NULL; struct archive *arch_preview = NULL; struct archive_entry *entry; - _cleanup_hashtable_unref_ GHashTable *matches = NULL; + g_autoptr(GHashTable) matches = NULL; /* populate a hash with all the files, symlinks and hardlinks that * actually need decompressing */ @@ -322,7 +322,7 @@ asb_utils_explode (const gchar *filename, } matches = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); for (;;) { - _cleanup_free_ gchar *path = NULL; + g_autofree gchar *path = NULL; r = archive_read_next_header (arch_preview, &entry); if (r == ARCHIVE_EOF) break; @@ -379,7 +379,7 @@ asb_utils_explode (const gchar *filename, goto out; } for (;;) { - _cleanup_free_ gchar *path = NULL; + g_autofree gchar *path = NULL; r = archive_read_next_header (arch, &entry); if (r == ARCHIVE_EOF) break; @@ -451,8 +451,8 @@ asb_utils_write_archive (const gchar *filename, archive_write_set_format_pax_restricted (a); archive_write_open_filename (a, filename); for (i = 0; i < files->len; i++) { - _cleanup_free_ gchar *data = NULL; - _cleanup_free_ gchar *filename_full = NULL; + g_autofree gchar *data = NULL; + g_autofree gchar *filename_full = NULL; tmp = g_ptr_array_index (files, i); filename_full = g_build_filename (path_orig, tmp, NULL); @@ -487,14 +487,14 @@ asb_utils_add_files_recursive (GPtrArray *files, const gchar *path_trailing; const gchar *tmp; guint path_orig_len; - _cleanup_dir_close_ GDir *dir = NULL; + g_autoptr(GDir) dir = NULL; dir = g_dir_open (path, 0, error); if (dir == NULL) return FALSE; path_orig_len = strlen (path_orig); while ((tmp = g_dir_read_name (dir)) != NULL) { - _cleanup_free_ gchar *path_new = NULL; + g_autofree gchar *path_new = NULL; path_new = g_build_filename (path, tmp, NULL); if (g_file_test (path_new, G_FILE_TEST_IS_DIR)) { if (!asb_utils_add_files_recursive (files, path_orig, path_new, error)) @@ -524,7 +524,7 @@ asb_utils_write_archive_dir (const gchar *filename, const gchar *directory, GError **error) { - _cleanup_ptrarray_unref_ GPtrArray *files = NULL; + g_autoptr(GPtrArray) files = NULL; /* add all files in the directory to the archive */ files = g_ptr_array_new_with_free_func (g_free); @@ -552,8 +552,8 @@ asb_utils_write_archive_dir (const gchar *filename, guint asb_string_replace (GString *string, const gchar *search, const gchar *replace) { - _cleanup_free_ gchar *tmp = NULL; - _cleanup_strv_free_ gchar **split = NULL; + g_autofree gchar *tmp = NULL; + g_auto(GStrv) split = NULL; /* quick search */ if (g_strstr_len (string->str, -1, search) == NULL) diff --git a/libappstream-builder/plugins/asb-plugin-absorb.c b/libappstream-builder/plugins/asb-plugin-absorb.c index 644cdd0..094a70e 100644 --- a/libappstream-builder/plugins/asb-plugin-absorb.c +++ b/libappstream-builder/plugins/asb-plugin-absorb.c @@ -93,7 +93,7 @@ asb_plugin_merge (AsbPlugin *plugin, GList *list) AsApp *found; GList *l; const gchar *tmp; - _cleanup_hashtable_unref_ GHashTable *hash = NULL; + g_autoptr(GHashTable) hash = NULL; /* add X-Merge-With-Parent on any metainfo files that are in a package * required by a desktop package */ diff --git a/libappstream-builder/plugins/asb-plugin-appdata.c b/libappstream-builder/plugins/asb-plugin-appdata.c index 15a6974..c9c44f9 100644 --- a/libappstream-builder/plugins/asb-plugin-appdata.c +++ b/libappstream-builder/plugins/asb-plugin-appdata.c @@ -86,8 +86,8 @@ asb_plugin_process_filename (AsbPlugin *plugin, GList *l; GList *list; guint i; - _cleanup_object_unref_ AsApp *appdata = NULL; - _cleanup_ptrarray_unref_ GPtrArray *problems = NULL; + g_autoptr(AsApp) appdata = NULL; + g_autoptr(GPtrArray) problems = NULL; /* validate */ appdata = as_app_new (); @@ -141,7 +141,7 @@ asb_plugin_process_filename (AsbPlugin *plugin, /* add provide if missing */ if (as_app_get_id_kind (appdata) == AS_ID_KIND_FIRMWARE && as_utils_guid_is_valid (tmp)) { - _cleanup_object_unref_ AsProvide *provide = NULL; + g_autoptr(AsProvide) provide = NULL; provide = as_provide_new (); as_provide_set_kind (provide, AS_PROVIDE_KIND_FIRMWARE_FLASHED); as_provide_set_value (provide, tmp); @@ -333,7 +333,7 @@ asb_plugin_process_app (AsbPlugin *plugin, GError **error) { GError *error_local = NULL; - _cleanup_free_ gchar *appdata_filename = NULL; + g_autofree gchar *appdata_filename = NULL; /* get possible sources */ if (asb_package_get_kind (pkg) == ASB_PACKAGE_KIND_FIRMWARE) { @@ -341,7 +341,7 @@ asb_plugin_process_app (AsbPlugin *plugin, as_app_get_metadata_item (AS_APP (app), "MetainfoBasename"), NULL); } else { - _cleanup_free_ gchar *appdata_basename = NULL; + g_autofree gchar *appdata_basename = NULL; appdata_basename = asb_plugin_appdata_get_fn_for_app (AS_APP (app)); appdata_filename = g_strdup_printf ("%s/files/share/appdata/%s.appdata.xml", tmpdir, appdata_basename); diff --git a/libappstream-builder/plugins/asb-plugin-dbus.c b/libappstream-builder/plugins/asb-plugin-dbus.c index c7f09d4..c0a861f 100644 --- a/libappstream-builder/plugins/asb-plugin-dbus.c +++ b/libappstream-builder/plugins/asb-plugin-dbus.c @@ -75,10 +75,10 @@ asb_plugin_process_dbus (AsbApp *app, gboolean is_system, GError **error) { - _cleanup_free_ gchar *filename_full = NULL; - _cleanup_free_ gchar *name = NULL; - _cleanup_keyfile_unref_ GKeyFile *kf = NULL; - _cleanup_object_unref_ AsProvide *provide = NULL; + g_autofree gchar *filename_full = NULL; + g_autofree gchar *name = NULL; + g_autoptr(GKeyFile) kf = NULL; + g_autoptr(AsProvide) provide = NULL; /* load file */ filename_full = g_build_filename (tmpdir, filename, NULL); diff --git a/libappstream-builder/plugins/asb-plugin-desktop.c b/libappstream-builder/plugins/asb-plugin-desktop.c index 2be20de..ec412c1 100644 --- a/libappstream-builder/plugins/asb-plugin-desktop.c +++ b/libappstream-builder/plugins/asb-plugin-desktop.c @@ -90,8 +90,8 @@ asb_app_load_icon (AsbApp *app, guint pixbuf_width; guint tmp_height; guint tmp_width; - _cleanup_object_unref_ GdkPixbuf *pixbuf_src = NULL; - _cleanup_object_unref_ GdkPixbuf *pixbuf_tmp = NULL; + g_autoptr(GdkPixbuf) pixbuf_src = NULL; + g_autoptr(GdkPixbuf) pixbuf_tmp = NULL; /* open file in native size */ if (g_str_has_suffix (filename, ".svg")) { @@ -134,7 +134,7 @@ asb_app_load_icon (AsbApp *app, /* never scale up, just pad */ if (pixbuf_width < icon_size && pixbuf_height < icon_size) { - _cleanup_free_ gchar *size_str = NULL; + g_autofree gchar *size_str = NULL; size_str = g_strdup_printf ("%ix%i", pixbuf_width, pixbuf_height); @@ -197,14 +197,14 @@ asb_plugin_desktop_add_icons (AsbPlugin *plugin, GError **error) { guint min_icon_size; - _cleanup_free_ gchar *fn_hidpi = NULL; - _cleanup_free_ gchar *fn = NULL; - _cleanup_free_ gchar *name_hidpi = NULL; - _cleanup_free_ gchar *name = NULL; - _cleanup_object_unref_ AsIcon *icon_hidpi = NULL; - _cleanup_object_unref_ AsIcon *icon = NULL; - _cleanup_object_unref_ GdkPixbuf *pixbuf_hidpi = NULL; - _cleanup_object_unref_ GdkPixbuf *pixbuf = NULL; + g_autofree gchar *fn_hidpi = NULL; + g_autofree gchar *fn = NULL; + g_autofree gchar *name_hidpi = NULL; + g_autofree gchar *name = NULL; + g_autoptr(AsIcon) icon_hidpi = NULL; + g_autoptr(AsIcon) icon = NULL; + g_autoptr(GdkPixbuf) pixbuf_hidpi = NULL; + g_autoptr(GdkPixbuf) pixbuf = NULL; /* find 64x64 icon */ fn = as_utils_find_icon_filename_full (tmpdir, key, @@ -314,10 +314,10 @@ asb_plugin_process_filename (AsbPlugin *plugin, AsIcon *icon; AsAppParseFlags parse_flags = AS_APP_PARSE_FLAG_USE_HEURISTICS; gboolean ret; - _cleanup_free_ gchar *app_id = NULL; - _cleanup_free_ gchar *full_filename = NULL; - _cleanup_object_unref_ AsbApp *app = NULL; - _cleanup_object_unref_ GdkPixbuf *pixbuf = NULL; + g_autofree gchar *app_id = NULL; + g_autofree gchar *full_filename = NULL; + g_autoptr(AsbApp) app = NULL; + g_autoptr(GdkPixbuf) pixbuf = NULL; /* use GenericName fallback */ if (asb_context_get_flag (plugin->ctx, ASB_CONTEXT_FLAG_USE_FALLBACKS)) @@ -346,14 +346,14 @@ asb_plugin_process_filename (AsbPlugin *plugin, /* is the icon a stock-icon-name? */ icon = as_app_get_icon_default (AS_APP (app)); if (icon != NULL) { - _cleanup_free_ gchar *key = NULL; + g_autofree gchar *key = NULL; key = g_strdup (as_icon_get_name (icon)); if (as_icon_get_kind (icon) == AS_ICON_KIND_STOCK) { asb_package_log (pkg, ASB_PACKAGE_LOG_LEVEL_DEBUG, "using stock icon %s", key); } else { - _cleanup_error_free_ GError *error_local = NULL; + g_autoptr(GError) error_local = NULL; g_ptr_array_set_size (as_app_get_icons (AS_APP (app)), 0); ret = asb_plugin_desktop_add_icons (plugin, app, diff --git a/libappstream-builder/plugins/asb-plugin-firmware.c b/libappstream-builder/plugins/asb-plugin-firmware.c index 64de525..bd98f07 100644 --- a/libappstream-builder/plugins/asb-plugin-firmware.c +++ b/libappstream-builder/plugins/asb-plugin-firmware.c @@ -90,7 +90,7 @@ asb_plugin_firmware_get_checksum (const gchar *filename, GError **error) { gsize len; - _cleanup_free_ gchar *data = NULL; + g_autofree gchar *data = NULL; if (!g_file_get_contents (filename, &data, &len, error)) return NULL; @@ -111,12 +111,12 @@ asb_plugin_process_filename (AsbPlugin *plugin, AsRelease *release; GError *error_local = NULL; const gchar *fw_basename = NULL; - _cleanup_free_ gchar *checksum = NULL; - _cleanup_free_ gchar *filename_full = NULL; - _cleanup_free_ gchar *location_checksum = NULL; - _cleanup_free_ gchar *metainfo_fn = NULL; - _cleanup_object_unref_ AsbApp *app = NULL; - _cleanup_object_unref_ AsChecksum *csum = NULL; + g_autofree gchar *checksum = NULL; + g_autofree gchar *filename_full = NULL; + g_autofree gchar *location_checksum = NULL; + g_autofree gchar *metainfo_fn = NULL; + g_autoptr(AsbApp) app = NULL; + g_autoptr(AsChecksum) csum = NULL; /* parse */ filename_full = g_build_filename (tmpdir, filename, NULL); @@ -160,9 +160,9 @@ asb_plugin_process_filename (AsbPlugin *plugin, /* set the internal checksum */ fw_basename = as_app_get_metadata_item (AS_APP (app), "FirmwareBasename"); if (fw_basename != NULL) { - _cleanup_free_ gchar *checksum_bin = NULL; - _cleanup_free_ gchar *fn_bin = NULL; - _cleanup_object_unref_ AsChecksum *csum_bin = NULL; + g_autofree gchar *checksum_bin = NULL; + g_autofree gchar *fn_bin = NULL; + g_autoptr(AsChecksum) csum_bin = NULL; /* add the checksum for the .bin file */ fn_bin = g_build_filename (tmpdir, fw_basename, NULL); diff --git a/libappstream-builder/plugins/asb-plugin-font.c b/libappstream-builder/plugins/asb-plugin-font.c index a8d55c3..b79669c 100644 --- a/libappstream-builder/plugins/asb-plugin-font.c +++ b/libappstream-builder/plugins/asb-plugin-font.c @@ -82,7 +82,7 @@ asb_font_fix_metadata (AsbApp *app) const gchar *value; gint percentage; guint j; - _cleanup_list_free_ GList *langs = NULL; + g_autoptr(GList) langs = NULL; _cleanup_string_free_ GString *str = NULL; struct { const gchar *lang; @@ -203,7 +203,7 @@ asb_font_fix_metadata (AsbApp *app) "FontIconText", "Aa"); } else { - _cleanup_free_ gchar *icon_tmp = NULL; + g_autofree gchar *icon_tmp = NULL; icon_tmp = g_utf8_substring (value, 0, 2); as_app_add_metadata (AS_APP (app), "FontIconText", @@ -273,7 +273,7 @@ asb_font_add_metadata (AsbApp *app, FT_Face ft_face) for (i = 0; i < len; i++) { FT_Get_Sfnt_Name (ft_face, i, &sfname); for (j = 0; tt_idx_to_md_name[j].key != NULL; j++) { - _cleanup_free_ gchar *val = NULL; + g_autofree gchar *val = NULL; if (sfname.name_id != tt_idx_to_md_name[j].idx) continue; val = g_locale_to_utf8 ((gchar *) sfname.string, @@ -415,14 +415,14 @@ asb_font_add_screenshot (AsbPlugin *plugin, AsbApp *app, FT_Face ft_face, const gchar *temp_dir; const gchar *tmp; guint i; - _cleanup_free_ gchar *basename = NULL; - _cleanup_free_ gchar *cache_fn = NULL; - _cleanup_free_ gchar *output_fn = NULL; - _cleanup_free_ gchar *caption = NULL; - _cleanup_free_ gchar *url_tmp = NULL; - _cleanup_object_unref_ AsImage *im = NULL; - _cleanup_object_unref_ AsScreenshot *ss = NULL; - _cleanup_object_unref_ GdkPixbuf *pixbuf = NULL; + g_autofree gchar *basename = NULL; + g_autofree gchar *cache_fn = NULL; + g_autofree gchar *output_fn = NULL; + g_autofree gchar *caption = NULL; + g_autofree gchar *url_tmp = NULL; + g_autoptr(AsImage) im = NULL; + g_autoptr(AsScreenshot) ss = NULL; + g_autoptr(GdkPixbuf) pixbuf = NULL; tmp = as_app_get_metadata_item (AS_APP (app), "FontSampleText"); if (tmp == NULL) @@ -588,7 +588,7 @@ asb_plugin_font_set_name (AsbApp *app, const gchar *name) " GPL&GNU", " SC", NULL }; - _cleanup_free_ gchar *tmp = NULL; + g_autofree gchar *tmp = NULL; /* remove font foundary suffix */ tmp = g_strdup (name); @@ -624,10 +624,10 @@ asb_plugin_font_app (AsbPlugin *plugin, AsbApp *app, gboolean ret = TRUE; guint i; const FcPattern *pattern; - _cleanup_free_ gchar *cache_id = NULL; - _cleanup_free_ gchar *comment = NULL; - _cleanup_free_ gchar *icon_filename = NULL; - _cleanup_object_unref_ GdkPixbuf *pixbuf = NULL; + g_autofree gchar *cache_id = NULL; + g_autofree gchar *comment = NULL; + g_autofree gchar *icon_filename = NULL; + g_autoptr(GdkPixbuf) pixbuf = NULL; /* create a new fontconfig configuration */ config = FcConfigCreate (); @@ -695,7 +695,7 @@ asb_plugin_font_app (AsbPlugin *plugin, AsbApp *app, /* generate icon */ tmp = as_app_get_metadata_item (AS_APP (app), "FontIconText"); if (tmp != NULL) { - _cleanup_object_unref_ AsIcon *icon = NULL; + g_autoptr(AsIcon) icon = NULL; pixbuf = asb_font_get_pixbuf (ft_face, 64, 64, tmp, error); if (pixbuf == NULL) { ret = FALSE; @@ -753,7 +753,7 @@ asb_plugin_process_app (AsbPlugin *plugin, filelist = asb_package_get_filelist (pkg); for (i = 0; filelist[i] != NULL; i++) { GError *error_local = NULL; - _cleanup_free_ gchar *filename = NULL; + g_autofree gchar *filename = NULL; if (!_asb_plugin_check_filename (filelist[i])) continue; @@ -781,7 +781,7 @@ asb_plugin_merge (AsbPlugin *plugin, GList *list) GList *l; GPtrArray *extends_tmp; const gchar *tmp; - _cleanup_hashtable_unref_ GHashTable *hash = NULL; + g_autoptr(GHashTable) hash = NULL; /* add all the fonts to a hash */ hash = g_hash_table_new_full (g_str_hash, g_str_equal, diff --git a/libappstream-builder/plugins/asb-plugin-gettext.c b/libappstream-builder/plugins/asb-plugin-gettext.c index 97cde4c..e7662ce 100644 --- a/libappstream-builder/plugins/asb-plugin-gettext.c +++ b/libappstream-builder/plugins/asb-plugin-gettext.c @@ -123,7 +123,7 @@ asb_gettext_parse_file (AsbGettextContext *ctx, { AsbGettextEntry *entry; AsbGettextHeader *h; - _cleanup_free_ gchar *data = NULL; + g_autofree gchar *data = NULL; gboolean swapped; /* read data, although we only strictly need the header */ @@ -160,8 +160,8 @@ asb_gettext_ctx_search_locale (AsbGettextContext *ctx, { const gchar *filename; guint i; - _cleanup_dir_close_ GDir *dir = NULL; - _cleanup_ptrarray_unref_ GPtrArray *mo_paths = NULL; + g_autoptr(GDir) dir = NULL; + g_autoptr(GPtrArray) mo_paths = NULL; dir = g_dir_open (messages_path, 0, error); if (dir == NULL) @@ -170,7 +170,7 @@ asb_gettext_ctx_search_locale (AsbGettextContext *ctx, /* do a first pass at this, trying to find the prefered .mo */ mo_paths = g_ptr_array_new_with_free_func (g_free); while ((filename = g_dir_read_name (dir)) != NULL) { - _cleanup_free_ gchar *path = NULL; + g_autofree gchar *path = NULL; path = g_build_filename (messages_path, filename, NULL); if (!g_file_test (path, G_FILE_TEST_EXISTS)) continue; @@ -210,8 +210,8 @@ asb_gettext_ctx_search_path (AsbGettextContext *ctx, const gchar *filename; AsbGettextEntry *e; GList *l; - _cleanup_dir_close_ GDir *dir = NULL; - _cleanup_free_ gchar *root = NULL; + g_autoptr(GDir) dir = NULL; + g_autofree gchar *root = NULL; /* search for .mo files in the prefix */ root = g_build_filename (prefix, "/usr/share/locale", NULL); @@ -225,7 +225,7 @@ asb_gettext_ctx_search_path (AsbGettextContext *ctx, if (dir == NULL) return FALSE; while ((filename = g_dir_read_name (dir)) != NULL) { - _cleanup_free_ gchar *path = NULL; + g_autofree gchar *path = NULL; path = g_build_filename (root, filename, "LC_MESSAGES", NULL); if (g_file_test (path, G_FILE_TEST_EXISTS)) { if (!asb_gettext_ctx_search_locale (ctx, filename, path, error)) diff --git a/libappstream-builder/plugins/asb-plugin-gir.c b/libappstream-builder/plugins/asb-plugin-gir.c index 8244bdb..854cb85 100644 --- a/libappstream-builder/plugins/asb-plugin-gir.c +++ b/libappstream-builder/plugins/asb-plugin-gir.c @@ -67,8 +67,8 @@ asb_plugin_process_gir (AsbApp *app, const gchar *name; const gchar *version; gboolean ret = TRUE; - _cleanup_free_ gchar *filename_full = NULL; - _cleanup_object_unref_ GFile *file = NULL; + g_autofree gchar *filename_full = NULL; + g_autoptr(GFile) file = NULL; /* load file */ filename_full = g_build_filename (tmpdir, filename, NULL); diff --git a/libappstream-builder/plugins/asb-plugin-gresource.c b/libappstream-builder/plugins/asb-plugin-gresource.c index 7703b16..d6eebb8 100644 --- a/libappstream-builder/plugins/asb-plugin-gresource.c +++ b/libappstream-builder/plugins/asb-plugin-gresource.c @@ -45,8 +45,8 @@ static gboolean asb_plugin_gresource_app (AsbApp *app, const gchar *filename, GError **error) { gboolean ret; - _cleanup_free_ gchar *data_err = NULL; - _cleanup_free_ gchar *data_out = NULL; + g_autofree gchar *data_err = NULL; + g_autofree gchar *data_out = NULL; const gchar *argv[] = { "/usr/bin/gresource", "list", filename, @@ -85,7 +85,7 @@ asb_plugin_process_app (AsbPlugin *plugin, filelist = asb_package_get_filelist (pkg); for (i = 0; filelist[i] != NULL; i++) { GError *error_local = NULL; - _cleanup_free_ gchar *filename = NULL; + g_autofree gchar *filename = NULL; if (!asb_plugin_match_glob ("/usr/bin/*", filelist[i])) continue; diff --git a/libappstream-builder/plugins/asb-plugin-gstreamer.c b/libappstream-builder/plugins/asb-plugin-gstreamer.c index 6cf1eed..e44aac8 100644 --- a/libappstream-builder/plugins/asb-plugin-gstreamer.c +++ b/libappstream-builder/plugins/asb-plugin-gstreamer.c @@ -111,7 +111,7 @@ static const AsbGstreamerDescData data[] = { static gboolean asb_utils_is_file_in_tmpdir (const gchar *tmpdir, const gchar *filename) { - _cleanup_free_ gchar *tmp = NULL; + g_autofree gchar *tmp = NULL; tmp = g_build_filename (tmpdir, filename, NULL); return g_file_test (tmp, G_FILE_TEST_EXISTS); } @@ -140,9 +140,9 @@ asb_plugin_process (AsbPlugin *plugin, GPtrArray *keywords; guint i; guint j; - _cleanup_free_ gchar *app_id = NULL; - _cleanup_object_unref_ AsbApp *app = NULL; - _cleanup_object_unref_ AsIcon *icon = NULL; + g_autofree gchar *app_id = NULL; + g_autoptr(AsbApp) app = NULL; + g_autoptr(AsIcon) icon = NULL; _cleanup_string_free_ GString *str = NULL; /* use the pkgname suffix as the app-id */ diff --git a/libappstream-builder/plugins/asb-plugin-ibus-sql.c b/libappstream-builder/plugins/asb-plugin-ibus-sql.c index 66f5fb5..6a6919c 100644 --- a/libappstream-builder/plugins/asb-plugin-ibus-sql.c +++ b/libappstream-builder/plugins/asb-plugin-ibus-sql.c @@ -91,14 +91,14 @@ asb_plugin_process_filename (AsbPlugin *plugin, gint rc; guint i; sqlite3 *db = NULL; - _cleanup_free_ gchar *basename = NULL; - _cleanup_free_ gchar *description = NULL; - _cleanup_free_ gchar *language_string = NULL; - _cleanup_free_ gchar *name = NULL; - _cleanup_free_ gchar *symbol = NULL; - _cleanup_object_unref_ AsbApp *app = NULL; - _cleanup_object_unref_ AsIcon *icon = NULL; - _cleanup_strv_free_ gchar **languages = NULL; + g_autofree gchar *basename = NULL; + g_autofree gchar *description = NULL; + g_autofree gchar *language_string = NULL; + g_autofree gchar *name = NULL; + g_autofree gchar *symbol = NULL; + g_autoptr(AsbApp) app = NULL; + g_autoptr(AsIcon) icon = NULL; + g_auto(GStrv) languages = NULL; /* open IME database */ filename_tmp = g_build_filename (tmpdir, filename, NULL); diff --git a/libappstream-builder/plugins/asb-plugin-ibus-xml.c b/libappstream-builder/plugins/asb-plugin-ibus-xml.c index 0638725..f5180fb 100644 --- a/libappstream-builder/plugins/asb-plugin-ibus-xml.c +++ b/libappstream-builder/plugins/asb-plugin-ibus-xml.c @@ -82,13 +82,13 @@ asb_plugin_process_filename (AsbPlugin *plugin, gboolean found_header = FALSE; gboolean ret; guint i; - _cleanup_free_ gchar *basename = NULL; - _cleanup_free_ gchar *data = NULL; - _cleanup_free_ gchar *filename_tmp = NULL; - _cleanup_object_unref_ AsbApp *app = NULL; - _cleanup_object_unref_ AsIcon *icon = NULL; - _cleanup_strv_free_ gchar **languages = NULL; - _cleanup_strv_free_ gchar **lines = NULL; + g_autofree gchar *basename = NULL; + g_autofree gchar *data = NULL; + g_autofree gchar *filename_tmp = NULL; + g_autoptr(AsbApp) app = NULL; + g_autoptr(AsIcon) icon = NULL; + g_auto(GStrv) languages = NULL; + g_auto(GStrv) lines = NULL; /* open file */ filename_tmp = g_build_filename (tmpdir, filename, NULL); diff --git a/libappstream-builder/plugins/asb-plugin-kde-services.c b/libappstream-builder/plugins/asb-plugin-kde-services.c index 1db073a..cf0e830 100644 --- a/libappstream-builder/plugins/asb-plugin-kde-services.c +++ b/libappstream-builder/plugins/asb-plugin-kde-services.c @@ -51,8 +51,8 @@ asb_plugin_process_filename (const gchar *filename, const gchar *tmpdir, GError **error) { - _cleanup_free_ gchar *types = NULL; - _cleanup_keyfile_unref_ GKeyFile *kf = NULL; + g_autofree gchar *types = NULL; + g_autoptr(GKeyFile) kf = NULL; kf = g_key_file_new (); if (!g_key_file_load_from_file (kf, filename, G_KEY_FILE_NONE, error)) return FALSE; @@ -82,8 +82,8 @@ asb_plugin_process_app (AsbPlugin *plugin, /* look for a krunner provider */ filelist = asb_package_get_filelist (pkg); for (i = 0; filelist[i] != NULL; i++) { - _cleanup_error_free_ GError *error_local = NULL; - _cleanup_free_ gchar *filename = NULL; + g_autoptr(GError) error_local = NULL; + g_autofree gchar *filename = NULL; if (!asb_plugin_match_glob ("/usr/share/kde4/services/*.desktop", filelist[i])) continue; filename = g_build_filename (tmpdir, filelist[i], NULL); diff --git a/libappstream-builder/plugins/asb-plugin-metainfo.c b/libappstream-builder/plugins/asb-plugin-metainfo.c index 9a3f2e1..5f54d65 100644 --- a/libappstream-builder/plugins/asb-plugin-metainfo.c +++ b/libappstream-builder/plugins/asb-plugin-metainfo.c @@ -72,7 +72,7 @@ asb_plugin_process_filename (AsbPlugin *plugin, GList **apps, GError **error) { - _cleanup_object_unref_ AsbApp *app = NULL; + g_autoptr(AsbApp) app = NULL; app = asb_app_new (pkg, NULL); if (!as_app_parse_file (AS_APP (app), filename, @@ -110,7 +110,7 @@ asb_plugin_process (AsbPlugin *plugin, filelist = asb_package_get_filelist (pkg); for (i = 0; filelist[i] != NULL; i++) { - _cleanup_free_ gchar *filename_tmp = NULL; + g_autofree gchar *filename_tmp = NULL; if (!_asb_plugin_check_filename (filelist[i])) continue; filename_tmp = g_build_filename (tmpdir, filelist[i], NULL); @@ -146,7 +146,7 @@ asb_plugin_merge (AsbPlugin *plugin, GList *list) AsApp *app; AsApp *found; GList *l; - _cleanup_hashtable_unref_ GHashTable *hash = NULL; + g_autoptr(GHashTable) hash = NULL; /* make a hash table of ID->AsApp */ hash = g_hash_table_new_full (g_str_hash, g_str_equal, diff --git a/libappstream-builder/plugins/asb-plugin-nm.c b/libappstream-builder/plugins/asb-plugin-nm.c index 569e9df..e583581 100644 --- a/libappstream-builder/plugins/asb-plugin-nm.c +++ b/libappstream-builder/plugins/asb-plugin-nm.c @@ -45,8 +45,8 @@ static gboolean asb_plugin_nm_app (AsbApp *app, const gchar *filename, GError **error) { gboolean ret; - _cleanup_free_ gchar *data_err = NULL; - _cleanup_free_ gchar *data_out = NULL; + g_autofree gchar *data_err = NULL; + g_autofree gchar *data_out = NULL; const gchar *argv[] = { "/usr/bin/nm", "--dynamic", "--no-sort", @@ -91,7 +91,7 @@ asb_plugin_process_app (AsbPlugin *plugin, filelist = asb_package_get_filelist (pkg); for (i = 0; filelist[i] != NULL; i++) { GError *error_local = NULL; - _cleanup_free_ gchar *filename = NULL; + g_autofree gchar *filename = NULL; if (!asb_plugin_match_glob ("/usr/bin/*", filelist[i])) continue; diff --git a/libappstream-builder/plugins/asb-plugin-ostree.c b/libappstream-builder/plugins/asb-plugin-ostree.c index a07fc7f..c9729a8 100644 --- a/libappstream-builder/plugins/asb-plugin-ostree.c +++ b/libappstream-builder/plugins/asb-plugin-ostree.c @@ -48,9 +48,9 @@ asb_plugin_add_globs (AsbPlugin *plugin, GPtrArray *globs) static gboolean asb_plugin_process_filename (const gchar *filename, AsbApp *app, GError **error) { - _cleanup_free_ gchar *app_runtime = NULL; - _cleanup_free_ gchar *app_sdk = NULL; - _cleanup_keyfile_unref_ GKeyFile *kf = NULL; + g_autofree gchar *app_runtime = NULL; + g_autofree gchar *app_sdk = NULL; + g_autoptr(GKeyFile) kf = NULL; kf = g_key_file_new (); if (!g_key_file_load_from_file (kf, filename, G_KEY_FILE_NONE, error)) return FALSE; @@ -81,8 +81,8 @@ asb_plugin_process_app (AsbPlugin *plugin, /* look for a krunner provider */ filelist = asb_package_get_filelist (pkg); for (i = 0; filelist[i] != NULL; i++) { - _cleanup_error_free_ GError *error_local = NULL; - _cleanup_free_ gchar *filename = NULL; + g_autoptr(GError) error_local = NULL; + g_autofree gchar *filename = NULL; if (!asb_plugin_match_glob ("/metadata", filelist[i])) continue; filename = g_build_filename (tmpdir, filelist[i], NULL); diff --git a/libappstream-glib/as-app-desktop.c b/libappstream-glib/as-app-desktop.c index 72bcbfe..ebdbdfa 100644 --- a/libappstream-glib/as-app-desktop.c +++ b/libappstream-glib/as-app-desktop.c @@ -56,7 +56,7 @@ as_app_infer_file_key (AsApp *app, const gchar *key, GError **error) { - _cleanup_free_ gchar *tmp = NULL; + g_autofree gchar *tmp = NULL; if (g_strcmp0 (key, "X-GNOME-UsesNotifications") == 0) { as_app_add_kudo_kind (AS_APP (app), @@ -131,9 +131,9 @@ as_app_parse_file_key (AsApp *app, gchar *dot = NULL; guint i; guint j; - _cleanup_free_ gchar *locale = NULL; - _cleanup_free_ gchar *tmp = NULL; - _cleanup_strv_free_ gchar **list = NULL; + g_autofree gchar *locale = NULL; + g_autofree gchar *tmp = NULL; + g_auto(GStrv) list = NULL; /* NoDisplay */ if (g_strcmp0 (key, G_KEY_FILE_DESKTOP_KEY_NO_DISPLAY) == 0) { @@ -165,7 +165,7 @@ as_app_parse_file_key (AsApp *app, key, NULL); if (tmp != NULL && tmp[0] != '\0') { - _cleanup_object_unref_ AsIcon *icon = NULL; + g_autoptr(AsIcon) icon = NULL; icon = as_icon_new (); as_icon_set_name (icon, tmp); dot = g_strstr_len (tmp, -1, "."); @@ -227,7 +227,7 @@ as_app_parse_file_key (AsApp *app, key, NULL, NULL); for (i = 0; list[i] != NULL; i++) { - _cleanup_strv_free_ gchar **kw_split = NULL; + g_auto(GStrv) kw_split = NULL; kw_split = g_strsplit (list[i], ",", -1); for (j = 0; kw_split[j] != NULL; j++) { if (kw_split[j][0] == '\0') @@ -244,7 +244,7 @@ as_app_parse_file_key (AsApp *app, locale, NULL, NULL); for (i = 0; list[i] != NULL; i++) { - _cleanup_strv_free_ gchar **kw_split = NULL; + g_auto(GStrv) kw_split = NULL; kw_split = g_strsplit (list[i], ",", -1); for (j = 0; kw_split[j] != NULL; j++) { if (kw_split[j][0] == '\0') @@ -352,8 +352,8 @@ as_app_parse_file_key_fallback_comment (AsApp *app, const gchar *key, GError **error) { - _cleanup_free_ gchar *locale = NULL; - _cleanup_free_ gchar *tmp = NULL; + g_autofree gchar *locale = NULL; + g_autofree gchar *tmp = NULL; /* GenericName */ if (g_strcmp0 (key, G_KEY_FILE_DESKTOP_KEY_GENERIC_NAME) == 0 || @@ -392,10 +392,10 @@ as_app_parse_desktop_file (AsApp *app, GKeyFileFlags kf_flags = G_KEY_FILE_KEEP_TRANSLATIONS; gchar *tmp; guint i; - _cleanup_error_free_ GError *error_local = NULL; - _cleanup_free_ gchar *app_id = NULL; - _cleanup_keyfile_unref_ GKeyFile *kf = NULL; - _cleanup_strv_free_ gchar **keys = NULL; + g_autoptr(GError) error_local = NULL; + g_autofree gchar *app_id = NULL; + g_autoptr(GKeyFile) kf = NULL; + g_auto(GStrv) keys = NULL; /* load file */ kf = g_key_file_new (); diff --git a/libappstream-glib/as-app-inf.c b/libappstream-glib/as-app-inf.c index 9389108..9515857 100644 --- a/libappstream-glib/as-app-inf.c +++ b/libappstream-glib/as-app-inf.c @@ -56,27 +56,27 @@ as_app_parse_inf_file (AsApp *app, GError **error) { guint64 timestamp; - _cleanup_error_free_ GError *error_local = NULL; - _cleanup_free_ gchar *appstream_id = NULL; - _cleanup_free_ gchar *catalog_basename = NULL; - _cleanup_free_ gchar *class_guid = NULL; - _cleanup_free_ gchar *class_guid_unsafe = NULL; - _cleanup_free_ gchar *class = NULL; - _cleanup_free_ gchar *comment = NULL; - _cleanup_free_ gchar *filename_full = NULL; - _cleanup_free_ gchar *firmware_basename = NULL; - _cleanup_free_ gchar *guid = NULL; - _cleanup_free_ gchar *provide_guid = NULL; - _cleanup_free_ gchar *location_checksum = NULL; - _cleanup_free_ gchar *name = NULL; - _cleanup_free_ gchar *srcpkg = NULL; - _cleanup_free_ gchar *vendor = NULL; - _cleanup_free_ gchar *version = NULL; - _cleanup_keyfile_unref_ GKeyFile *kf = NULL; - _cleanup_object_unref_ AsIcon *icon = NULL; - _cleanup_object_unref_ AsProvide *provide = NULL; - _cleanup_object_unref_ AsRelease *release = NULL; - _cleanup_strv_free_ gchar **source_keys = NULL; + g_autoptr(GError) error_local = NULL; + g_autofree gchar *appstream_id = NULL; + g_autofree gchar *catalog_basename = NULL; + g_autofree gchar *class_guid = NULL; + g_autofree gchar *class_guid_unsafe = NULL; + g_autofree gchar *class = NULL; + g_autofree gchar *comment = NULL; + g_autofree gchar *filename_full = NULL; + g_autofree gchar *firmware_basename = NULL; + g_autofree gchar *guid = NULL; + g_autofree gchar *provide_guid = NULL; + g_autofree gchar *location_checksum = NULL; + g_autofree gchar *name = NULL; + g_autofree gchar *srcpkg = NULL; + g_autofree gchar *vendor = NULL; + g_autofree gchar *version = NULL; + g_autoptr(GKeyFile) kf = NULL; + g_autoptr(AsIcon) icon = NULL; + g_autoptr(AsProvide) provide = NULL; + g_autoptr(AsRelease) release = NULL; + g_auto(GStrv) source_keys = NULL; /* load file */ kf = g_key_file_new (); diff --git a/libappstream-glib/as-app-validate.c b/libappstream-glib/as-app-validate.c index 1d8bc41..6e1fc25 100644 --- a/libappstream-glib/as-app-validate.c +++ b/libappstream-glib/as-app-validate.c @@ -54,7 +54,7 @@ ai_app_validate_add (AsAppValidateHelper *helper, AsProblem *problem; guint i; va_list args; - _cleanup_free_ gchar *str = NULL; + g_autofree gchar *str = NULL; va_start (args, fmt); str = g_strdup_vprintf (fmt, args); @@ -139,7 +139,7 @@ as_app_validate_has_email (const gchar *text) static gboolean as_app_validate_has_first_word_capital (AsAppValidateHelper *helper, const gchar *text) { - _cleanup_free_ gchar *first_word = NULL; + g_autofree gchar *first_word = NULL; gchar *tmp; guint i; @@ -443,8 +443,8 @@ ai_app_validate_image_check (AsImage *im, AsAppValidateHelper *helper) guint ss_size_height_min = 351; guint ss_size_width_max = 1600; guint ss_size_width_min = 624; - _cleanup_object_unref_ GdkPixbuf *pixbuf = NULL; - _cleanup_object_unref_ GInputStream *stream = NULL; + g_autoptr(GdkPixbuf) pixbuf = NULL; + g_autoptr(GInputStream) stream = NULL; _cleanup_object_unref_ SoupMessage *msg = NULL; _cleanup_uri_unref_ SoupURI *base_uri = NULL; @@ -932,7 +932,7 @@ static gboolean as_app_validate_license (const gchar *license_text, GError **error) { guint i; - _cleanup_strv_free_ gchar **licenses = NULL; + g_auto(GStrv) licenses = NULL; licenses = as_utils_spdx_license_tokenize (license_text); for (i = 0; licenses[i] != NULL; i++) { @@ -961,7 +961,7 @@ static gboolean as_app_validate_is_content_license (const gchar *license) { guint i; - _cleanup_strv_free_ gchar **tokens = NULL; + g_auto(GStrv) tokens = NULL; tokens = as_utils_spdx_license_tokenize (license); for (i = 0; tokens[i] != NULL; i++) { if (g_strcmp0 (tokens[i], "@CC0-1.0") == 0) @@ -1034,7 +1034,7 @@ as_app_validate (AsApp *app, AsAppValidateFlags flags, GError **error) guint number_para_max = 4; guint number_para_min = 2; guint str_len; - _cleanup_list_free_ GList *keys = NULL; + g_autoptr(GList) keys = NULL; /* relax the requirements a bit */ if ((flags & AS_APP_VALIDATE_FLAG_RELAX) > 0) { diff --git a/libappstream-glib/as-app.c b/libappstream-glib/as-app.c index 4f5495a..e34f8b5 100644 --- a/libappstream-glib/as-app.c +++ b/libappstream-glib/as-app.c @@ -1564,7 +1564,7 @@ void as_app_set_metadata_license (AsApp *app, const gchar *metadata_license) { AsAppPrivate *priv = GET_PRIVATE (app); - _cleanup_strv_free_ gchar **tokens = NULL; + g_auto(GStrv) tokens = NULL; /* handle untrusted */ if ((priv->trust_flags & AS_APP_TRUST_FLAG_CHECK_VALID_UTF8) > 0 && @@ -1982,7 +1982,7 @@ as_app_add_keyword (AsApp *app, { AsAppPrivate *priv = GET_PRIVATE (app); GPtrArray *tmp; - _cleanup_free_ gchar *tmp_locale = NULL; + g_autofree gchar *tmp_locale = NULL; /* handle untrusted */ if ((priv->trust_flags & AS_APP_TRUST_FLAG_CHECK_VALID_UTF8) > 0 && @@ -2580,7 +2580,7 @@ as_app_subsume_dict (GHashTable *dest, GHashTable *src, gboolean overwrite) const gchar *tmp; const gchar *key; const gchar *value; - _cleanup_list_free_ GList *keys = NULL; + g_autoptr(GList) keys = NULL; keys = g_hash_table_get_keys (src); for (l = keys; l != NULL; l = l->next) { @@ -2607,7 +2607,7 @@ as_app_subsume_keywords (AsApp *app, AsApp *donor, gboolean overwrite) const gchar *key; const gchar *tmp; guint i; - _cleanup_list_free_ GList *keys = NULL; + g_autoptr(GList) keys = NULL; /* get all locales in the keywords dict */ keys = g_hash_table_get_keys (priv->keywords); @@ -2676,7 +2676,7 @@ as_app_subsume_private (AsApp *app, AsApp *donor, AsAppSubsumeFlags flags) guint i; gint percentage; GList *l; - _cleanup_list_free_ GList *keys = NULL; + g_autoptr(GList) keys = NULL; /* stop us shooting ourselves in the foot */ papp->trust_flags |= AS_APP_TRUST_FLAG_CHECK_DUPLICATES; @@ -2880,7 +2880,7 @@ as_app_node_insert_languages (AsApp *app, GNode *parent) const gchar *locale; gchar tmp[4]; gint percentage; - _cleanup_list_free_ GList *langs = NULL; + g_autoptr(GList) langs = NULL; node_tmp = as_node_insert (parent, "languages", NULL, 0, NULL); langs = as_app_get_languages (app); @@ -2953,7 +2953,7 @@ as_app_node_insert_keywords (AsApp *app, GNode *parent, AsNodeContext *ctx) const gchar *lang; const gchar *tmp; guint i; - _cleanup_hashtable_unref_ GHashTable *already_in_c = NULL; + g_autoptr(GHashTable) already_in_c = NULL; /* don't add localized keywords that already exist in C, e.g. * there's no point adding "c++" in 14 different languages */ @@ -3281,7 +3281,7 @@ as_app_node_parse_child (AsApp *app, GNode *n, AsAppParseFlags flags, /* <bundle> */ case AS_TAG_BUNDLE: { - _cleanup_object_unref_ AsBundle *ic = NULL; + g_autoptr(AsBundle) ic = NULL; ic = as_bundle_new (); if (!as_bundle_node_parse (ic, n, ctx, error)) return FALSE; @@ -3325,7 +3325,7 @@ as_app_node_parse_child (AsApp *app, GNode *n, AsAppParseFlags flags, /* unwrap appdata inline */ if (priv->source_kind == AS_APP_SOURCE_KIND_APPDATA) { GError *error_local = NULL; - _cleanup_hashtable_unref_ GHashTable *unwrapped = NULL; + g_autoptr(GHashTable) unwrapped = NULL; unwrapped = as_node_get_localized_unwrap (n, &error_local); if (unwrapped == NULL) { if (g_error_matches (error_local, @@ -3366,7 +3366,7 @@ as_app_node_parse_child (AsApp *app, GNode *n, AsAppParseFlags flags, /* <icon> */ case AS_TAG_ICON: { - _cleanup_object_unref_ AsIcon *ic = NULL; + g_autoptr(AsIcon) ic = NULL; ic = as_icon_new (); as_icon_set_prefix (ic, priv->icon_path); if (!as_icon_node_parse (ic, n, ctx, error)) @@ -3540,7 +3540,7 @@ as_app_node_parse_child (AsApp *app, GNode *n, AsAppParseFlags flags, if (!(flags & AS_APP_PARSE_FLAG_APPEND_DATA)) g_ptr_array_set_size (priv->screenshots, 0); for (c = n->children; c != NULL; c = c->next) { - _cleanup_object_unref_ AsScreenshot *ss = NULL; + g_autoptr(AsScreenshot) ss = NULL; if (as_node_get_tag (c) != AS_TAG_SCREENSHOT) continue; /* we don't yet support localised screenshots */ @@ -3558,7 +3558,7 @@ as_app_node_parse_child (AsApp *app, GNode *n, AsAppParseFlags flags, if (!(flags & AS_APP_PARSE_FLAG_APPEND_DATA)) g_ptr_array_set_size (priv->releases, 0); for (c = n->children; c != NULL; c = c->next) { - _cleanup_object_unref_ AsRelease *r = NULL; + g_autoptr(AsRelease) r = NULL; if (as_node_get_tag (c) != AS_TAG_RELEASE) continue; r = as_release_new (); @@ -3573,7 +3573,7 @@ as_app_node_parse_child (AsApp *app, GNode *n, AsAppParseFlags flags, if (!(flags & AS_APP_PARSE_FLAG_APPEND_DATA)) g_ptr_array_set_size (priv->provides, 0); for (c = n->children; c != NULL; c = c->next) { - _cleanup_object_unref_ AsProvide *p = NULL; + g_autoptr(AsProvide) p = NULL; p = as_provide_new (); if (!as_provide_node_parse (p, c, ctx, error)) return FALSE; @@ -3626,8 +3626,8 @@ as_app_check_for_hidpi_icons (AsApp *app) { AsAppPrivate *priv = GET_PRIVATE (app); AsIcon *icon_tmp; - _cleanup_free_ gchar *fn_size = NULL; - _cleanup_object_unref_ AsIcon *icon_hidpi = NULL; + g_autofree gchar *fn_size = NULL; + g_autoptr(AsIcon) icon_hidpi = NULL; /* does the file exist */ icon_tmp = as_app_get_icon_default (app); @@ -3721,7 +3721,7 @@ as_app_node_parse_dep11_icons (AsApp *app, GNode *node, const gchar *sizes[] = { "128x128", "64x64", "", NULL }; guint i; guint size; - _cleanup_object_unref_ AsIcon *ic_tmp = NULL; + g_autoptr(AsIcon) ic_tmp = NULL; /* YAML files only specify one icon for various sizes */ ic_tmp = as_icon_new (); @@ -3730,9 +3730,9 @@ as_app_node_parse_dep11_icons (AsApp *app, GNode *node, /* find each size */ for (i = 0; sizes[i] != NULL; i++) { - _cleanup_free_ gchar *path = NULL; - _cleanup_free_ gchar *size_name = NULL; - _cleanup_object_unref_ AsIcon *ic = NULL; + g_autofree gchar *path = NULL; + g_autofree gchar *size_name = NULL; + g_autoptr(AsIcon) ic = NULL; size_name = g_build_filename (sizes[i], as_icon_get_name (ic_tmp), @@ -3846,7 +3846,7 @@ as_app_node_parse_dep11 (AsApp *app, GNode *node, } if (g_strcmp0 (tmp, "Bundle") == 0) { for (c = n->children; c != NULL; c = c->next) { - _cleanup_object_unref_ AsBundle *bu = NULL; + g_autoptr(AsBundle) bu = NULL; bu = as_bundle_new (); if (!as_bundle_node_parse_dep11 (bu, c, ctx, error)) return FALSE; @@ -3874,7 +3874,7 @@ as_app_node_parse_dep11 (AsApp *app, GNode *node, } continue; } else { - _cleanup_object_unref_ AsProvide *pr = NULL; + g_autoptr(AsProvide) pr = NULL; pr = as_provide_new (); if (!as_provide_node_parse_dep11 (pr, c, ctx, error)) return FALSE; @@ -3885,7 +3885,7 @@ as_app_node_parse_dep11 (AsApp *app, GNode *node, } if (g_strcmp0 (tmp, "Screenshots") == 0) { for (c = n->children; c != NULL; c = c->next) { - _cleanup_object_unref_ AsScreenshot *ss = NULL; + g_autoptr(AsScreenshot) ss = NULL; ss = as_screenshot_new (); if (!as_screenshot_node_parse_dep11 (ss, c, ctx, error)) return FALSE; @@ -3905,8 +3905,8 @@ as_app_value_tokenize (const gchar *value) { gchar **values; guint i; - _cleanup_free_ gchar *delim = NULL; - _cleanup_strv_free_ gchar **tmp = NULL; + g_autofree gchar *delim = NULL; + g_auto(GStrv) tmp = NULL; delim = g_strdup (value); g_strdelimit (delim, "/,.;:", ' '); @@ -4231,9 +4231,9 @@ as_app_parse_appdata_file (AsApp *app, gboolean seen_application = FALSE; gchar *tmp; gsize len; - _cleanup_error_free_ GError *error_local = NULL; - _cleanup_free_ AsNodeContext *ctx = NULL; - _cleanup_free_ gchar *data = NULL; + g_autoptr(GError) error_local = NULL; + g_autofree AsNodeContext *ctx = NULL; + g_autofree gchar *data = NULL; _cleanup_node_unref_ GNode *root = NULL; /* open file */ @@ -4420,7 +4420,7 @@ as_app_to_file (AsApp *app, GCancellable *cancellable, GError **error) { - _cleanup_free_ AsNodeContext *ctx = NULL; + g_autofree AsNodeContext *ctx = NULL; _cleanup_node_unref_ GNode *root = NULL; _cleanup_string_free_ GString *xml = NULL; diff --git a/libappstream-glib/as-cleanup.h b/libappstream-glib/as-cleanup.h index 33c5f99..4c3641a 100644 --- a/libappstream-glib/as-cleanup.h +++ b/libappstream-glib/as-cleanup.h @@ -53,54 +53,21 @@ G_BEGIN_DECLS func (*(Type*)v, TRUE); \ } -GS_DEFINE_CLEANUP_FUNCTION0(GArray*, gs_local_array_unref, g_array_unref) -GS_DEFINE_CLEANUP_FUNCTION0(GBytes*, gs_local_bytes_unref, g_bytes_unref) -GS_DEFINE_CLEANUP_FUNCTION0(GChecksum*, gs_local_checksum_free, g_checksum_free) -GS_DEFINE_CLEANUP_FUNCTION0(GDateTime*, gs_local_date_time_unref, g_date_time_unref) -GS_DEFINE_CLEANUP_FUNCTION0(GDir*, gs_local_dir_close, g_dir_close) -GS_DEFINE_CLEANUP_FUNCTION0(GError*, gs_local_free_error, g_error_free) -GS_DEFINE_CLEANUP_FUNCTION0(GHashTable*, gs_local_hashtable_unref, g_hash_table_unref) -GS_DEFINE_CLEANUP_FUNCTION0(GKeyFile*, gs_local_keyfile_unref, g_key_file_unref) -GS_DEFINE_CLEANUP_FUNCTION0(GMarkupParseContext*, gs_local_markup_parse_context_unref, g_markup_parse_context_unref) GS_DEFINE_CLEANUP_FUNCTION0(GNode*, gs_local_node_unref, as_node_unref) GS_DEFINE_CLEANUP_FUNCTION0(GNode*, gs_local_yaml_unref, as_yaml_unref) GS_DEFINE_CLEANUP_FUNCTION0(GObject*, gs_local_obj_unref, g_object_unref) -GS_DEFINE_CLEANUP_FUNCTION0(GPtrArray*, gs_local_ptrarray_unref, g_ptr_array_unref) -GS_DEFINE_CLEANUP_FUNCTION0(GTimer*, gs_local_destroy_timer, g_timer_destroy) -GS_DEFINE_CLEANUP_FUNCTION0(GVariantBuilder*, gs_local_variant_builder_unref, g_variant_builder_unref) -GS_DEFINE_CLEANUP_FUNCTION0(GVariant*, gs_local_variant_unref, g_variant_unref) -GS_DEFINE_CLEANUP_FUNCTION0(GVariantIter*, gs_local_variant_iter_free, g_variant_iter_free) GS_DEFINE_CLEANUP_FUNCTION0(SoupURI*, gs_local_uri_unref, soup_uri_free) GS_DEFINE_CLEANUP_FUNCTIONt(GString*, gs_local_free_string, g_string_free) -GS_DEFINE_CLEANUP_FUNCTION(char**, gs_local_strfreev, g_strfreev) -GS_DEFINE_CLEANUP_FUNCTION(GList*, gs_local_free_list, g_list_free) -GS_DEFINE_CLEANUP_FUNCTION(void*, gs_local_free, g_free) - GS_DEFINE_CLEANUP_FUNCTION(void*, gs_local_free_libc, free) -#define _cleanup_date_time_unref_ __attribute__ ((cleanup(gs_local_date_time_unref))) -#define _cleanup_dir_close_ __attribute__ ((cleanup(gs_local_dir_close))) -#define _cleanup_timer_destroy_ __attribute__ ((cleanup(gs_local_destroy_timer))) -#define _cleanup_free_ __attribute__ ((cleanup(gs_local_free))) #define _cleanup_free_libc_ __attribute__ ((cleanup(gs_local_free_libc))) -#define _cleanup_checksum_free_ __attribute__ ((cleanup(gs_local_checksum_free))) -#define _cleanup_error_free_ __attribute__ ((cleanup(gs_local_free_error))) -#define _cleanup_list_free_ __attribute__ ((cleanup(gs_local_free_list))) #define _cleanup_string_free_ __attribute__ ((cleanup(gs_local_free_string))) -#define _cleanup_strv_free_ __attribute__ ((cleanup(gs_local_strfreev))) -#define _cleanup_array_unref_ __attribute__ ((cleanup(gs_local_array_unref))) -#define _cleanup_bytes_unref_ __attribute__ ((cleanup(gs_local_bytes_unref))) -#define _cleanup_hashtable_unref_ __attribute__ ((cleanup(gs_local_hashtable_unref))) -#define _cleanup_keyfile_unref_ __attribute__ ((cleanup(gs_local_keyfile_unref))) -#define _cleanup_markup_parse_context_unref_ __attribute__ ((cleanup(gs_local_markup_parse_context_unref))) #define _cleanup_node_unref_ __attribute__ ((cleanup(gs_local_node_unref))) #define _cleanup_yaml_unref_ __attribute__ ((cleanup(gs_local_yaml_unref))) #define _cleanup_object_unref_ __attribute__ ((cleanup(gs_local_obj_unref))) -#define _cleanup_ptrarray_unref_ __attribute__ ((cleanup(gs_local_ptrarray_unref))) #define _cleanup_uri_unref_ __attribute__ ((cleanup(gs_local_uri_unref))) -#define _cleanup_variant_unref_ __attribute__ ((cleanup(gs_local_variant_unref))) G_END_DECLS diff --git a/libappstream-glib/as-icon.c b/libappstream-glib/as-icon.c index dfdf37e..17eca74 100644 --- a/libappstream-glib/as-icon.c +++ b/libappstream-glib/as-icon.c @@ -496,7 +496,7 @@ as_icon_node_insert_embedded (AsIcon *icon, GNode *parent, AsNodeContext *ctx) { AsIconPrivate *priv = GET_PRIVATE (icon); GNode *n; - _cleanup_free_ gchar *data = NULL; + g_autofree gchar *data = NULL; /* embedded icon */ n = as_node_insert (parent, "icon", NULL, 0, @@ -573,9 +573,9 @@ as_icon_node_parse_embedded (AsIcon *icon, GNode *n, GError **error) AsIconPrivate *priv = GET_PRIVATE (icon); GNode *c; gsize size; - _cleanup_free_ guchar *data = NULL; - _cleanup_object_unref_ GdkPixbuf *pixbuf = NULL; - _cleanup_object_unref_ GInputStream *stream = NULL; + g_autofree guchar *data = NULL; + g_autoptr(GdkPixbuf) pixbuf = NULL; + g_autoptr(GInputStream) stream = NULL; /* get the icon name */ c = as_node_find (n, "name"); @@ -664,7 +664,7 @@ as_icon_node_parse (AsIcon *icon, GNode *node, if (g_strstr_len (tmp, -1, "/") == NULL) { as_icon_set_name (icon, tmp); } else { - _cleanup_free_ gchar *basename = NULL; + g_autofree gchar *basename = NULL; basename = g_path_get_basename (tmp); as_icon_set_name (icon, basename); } @@ -739,8 +739,8 @@ gboolean as_icon_load (AsIcon *icon, AsIconLoadFlags flags, GError **error) { AsIconPrivate *priv = GET_PRIVATE (icon); - _cleanup_free_ gchar *fn_fallback = NULL; - _cleanup_object_unref_ GdkPixbuf *pixbuf = NULL; + g_autofree gchar *fn_fallback = NULL; + g_autoptr(GdkPixbuf) pixbuf = NULL; /* absolute filename */ if (priv->kind == AS_ICON_KIND_LOCAL) { @@ -778,8 +778,8 @@ as_icon_load (AsIcon *icon, AsIconLoadFlags flags, GError **error) guint height[] = { priv->height, 64, 128, 0 }; guint i; for (i = 0; widths[i] != 0; i++) { - _cleanup_free_ gchar *fn_size = NULL; - _cleanup_free_ gchar *size_str = NULL; + g_autofree gchar *fn_size = NULL; + g_autofree gchar *size_str = NULL; size_str = g_strdup_printf ("%ix%i", widths[i], height[i]); fn_size = g_build_filename (priv->prefix, size_str, priv->name, NULL); if (g_file_test (fn_size, G_FILE_TEST_EXISTS)) { @@ -830,8 +830,8 @@ as_icon_convert_to_kind (AsIcon *icon, AsIconKind kind, GError **error) /* cached -> embedded */ if (priv->kind == AS_ICON_KIND_CACHED && kind == AS_ICON_KIND_EMBEDDED) { gsize data_size; - _cleanup_bytes_unref_ GBytes *tmp = NULL; - _cleanup_free_ gchar *data = NULL; + g_autoptr(GBytes) tmp = NULL; + g_autofree gchar *data = NULL; /* load the pixbuf and save it to a PNG buffer */ if (priv->pixbuf == NULL) { @@ -851,9 +851,9 @@ as_icon_convert_to_kind (AsIcon *icon, AsIconKind kind, GError **error) /* cached -> embedded */ if (priv->kind == AS_ICON_KIND_EMBEDDED && kind == AS_ICON_KIND_CACHED) { - _cleanup_free_ gchar *size_str = NULL; - _cleanup_free_ gchar *path = NULL; - _cleanup_free_ gchar *fn = NULL; + g_autofree gchar *size_str = NULL; + g_autofree gchar *path = NULL; + g_autofree gchar *fn = NULL; /* ensure the parent path exists */ size_str = g_strdup_printf ("%ix%i", priv->width, priv->height); diff --git a/libappstream-glib/as-image.c b/libappstream-glib/as-image.c index 661e5ee..be7fd28 100644 --- a/libappstream-glib/as-image.c +++ b/libappstream-glib/as-image.c @@ -498,9 +498,9 @@ as_image_load_filename (AsImage *image, { AsImagePrivate *priv = GET_PRIVATE (image); gsize len; - _cleanup_free_ gchar *basename = NULL; - _cleanup_free_ gchar *data = NULL; - _cleanup_object_unref_ GdkPixbuf *pixbuf = NULL; + g_autofree gchar *basename = NULL; + g_autofree gchar *data = NULL; + g_autoptr(GdkPixbuf) pixbuf = NULL; /* get the contents so we can hash the predictable file data, * rather than the unpredicatable (for JPEG) pixel data */ @@ -547,7 +547,7 @@ as_image_save_pixbuf (AsImage *image, guint tmp_width; guint pixbuf_height; guint pixbuf_width; - _cleanup_object_unref_ GdkPixbuf *pixbuf_tmp = NULL; + g_autoptr(GdkPixbuf) pixbuf_tmp = NULL; /* never set */ if (priv->pixbuf == NULL) @@ -630,7 +630,7 @@ as_image_save_filename (AsImage *image, AsImageSaveFlags flags, GError **error) { - _cleanup_object_unref_ GdkPixbuf *pixbuf = NULL; + g_autoptr(GdkPixbuf) pixbuf = NULL; /* save source file */ pixbuf = as_image_save_pixbuf (image, width, height, flags); diff --git a/libappstream-glib/as-inf.c b/libappstream-glib/as-inf.c index bfefe5c..e90a953 100644 --- a/libappstream-glib/as-inf.c +++ b/libappstream-glib/as-inf.c @@ -103,13 +103,13 @@ as_inf_replace_variable (AsInfHelper *helper, const gchar *line, GError **error) GString *new; const gchar *tmp; guint i; - _cleanup_strv_free_ gchar **split = NULL; + g_auto(GStrv) split = NULL; /* split up into sections of the delimiter */ new = g_string_sized_new (strlen (line)); split = g_strsplit (line, "%", -1); for (i = 0; split[i] != NULL; i++) { - _cleanup_free_ gchar *lower = NULL; + g_autofree gchar *lower = NULL; /* the text between the substitutions */ if (i % 2 == 0) { @@ -156,9 +156,9 @@ as_inf_get_dict (AsInfHelper *helper, GError **error) GHashTable *dict = NULL; gchar *val; guint i; - _cleanup_free_ gchar *lower = NULL; - _cleanup_hashtable_unref_ GHashTable *dict_tmp = NULL; - _cleanup_strv_free_ gchar **keys = NULL; + g_autofree gchar *lower = NULL; + g_autoptr(GHashTable) dict_tmp = NULL; + g_auto(GStrv) keys = NULL; dict_tmp = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); lower = as_inf_make_case_insensitive (helper, "Strings"); @@ -184,11 +184,11 @@ as_inf_replace_variables (AsInfHelper *helper, GError **error) { guint i; guint j; - _cleanup_strv_free_ gchar **groups = NULL; + g_auto(GStrv) groups = NULL; groups = g_key_file_get_groups (helper->keyfile, NULL); for (i = 0; groups[i] != NULL; i++) { - _cleanup_strv_free_ gchar **keys = NULL; + g_auto(GStrv) keys = NULL; /* ignore the source */ if (g_strcmp0 (groups[i], "Strings") == 0) @@ -199,8 +199,8 @@ as_inf_replace_variables (AsInfHelper *helper, GError **error) if (keys == NULL) continue; for (j = 0; keys[j] != NULL; j++) { - _cleanup_free_ gchar *data_old = NULL; - _cleanup_free_ gchar *data_new = NULL; + g_autofree gchar *data_old = NULL; + g_autofree gchar *data_new = NULL; /* get the old data for this [group] key */ data_old = g_key_file_get_string (helper->keyfile, @@ -488,7 +488,7 @@ as_inf_parse_line (AsInfHelper *helper, gchar *line, GError **error) guint len; gboolean ret = TRUE; gboolean continuation = FALSE; - _cleanup_free_ gchar *key = NULL; + g_autofree gchar *key = NULL; /* line too long */ if ((helper->flags & AS_INF_LOAD_FLAG_STRICT) > 0 && @@ -568,7 +568,7 @@ as_inf_parse_line (AsInfHelper *helper, gchar *line, GError **error) tmp = g_strstr_len (line, -1, "\""); if ((tmp == NULL && kvsplit != NULL) || (kvsplit != NULL && kvsplit < tmp)) { - _cleanup_free_ gchar *key_new = NULL; + g_autofree gchar *key_new = NULL; /* key=value before [group] */ if (helper->group == NULL) { @@ -589,7 +589,7 @@ as_inf_parse_line (AsInfHelper *helper, gchar *line, GError **error) /* convert key names with variables */ if (key[0] == '%') { - _cleanup_free_ gchar *key_tmp = NULL; + g_autofree gchar *key_tmp = NULL; if (helper->dict == NULL) { helper->require_2nd_pass = TRUE; helper->last_line_continuation_ignore = TRUE; @@ -627,8 +627,8 @@ as_inf_parse_line (AsInfHelper *helper, gchar *line, GError **error) /* last_line_continuation from the last line */ if (helper->last_line_continuation) { - _cleanup_free_ gchar *old = NULL; - _cleanup_free_ gchar *new = NULL; + g_autofree gchar *old = NULL; + g_autofree gchar *new = NULL; /* this is the 1st pass, and we have no key */ if (helper->last_line_continuation_ignore) @@ -695,7 +695,7 @@ as_inf_parse_line (AsInfHelper *helper, gchar *line, GError **error) if (g_strcmp0 (helper->group, "Firmware_AddReg") == 0 && g_str_has_prefix (line, "HK")) { guint i; - _cleanup_strv_free_ gchar **reg_split = NULL; + g_auto(GStrv) reg_split = NULL; _cleanup_string_free_ GString *str = NULL; str = g_string_new (""); reg_split = g_strsplit (line, ",", -1); @@ -706,7 +706,7 @@ as_inf_parse_line (AsInfHelper *helper, gchar *line, GError **error) g_string_append_printf (str, "%s_", reg_split[i]); } if (str->len > 0) { - _cleanup_free_ gchar *key_tmp = NULL; + g_autofree gchar *key_tmp = NULL; /* remove trailing '_' */ g_string_truncate (str, str->len - 1); @@ -790,7 +790,7 @@ as_inf_load_data (GKeyFile *keyfile, AsInfHelper *helper; gboolean ret = TRUE; guint i; - _cleanup_strv_free_ gchar **lines = NULL; + g_auto(GStrv) lines = NULL; /* initialize helper */ helper = as_inf_helper_new (); @@ -818,7 +818,7 @@ as_inf_load_data (GKeyFile *keyfile, /* lets do this all over again */ if (helper->require_2nd_pass) { - _cleanup_strv_free_ gchar **lines2 = NULL; + g_auto(GStrv) lines2 = NULL; lines2 = g_strsplit (data, "\n", -1); for (i = 0; lines2[i] != NULL; i++) { if (!as_inf_parse_line (helper, lines2[i], error)) { @@ -869,7 +869,7 @@ as_inf_load_file (GKeyFile *keyfile, const gchar *data_no_bom; gsize len; guint i; - _cleanup_free_ gchar *data = NULL; + g_autofree gchar *data = NULL; AsInfBOM boms[] = { { "\x00\x00\xfe\xff", "UTF-32BE", 4 }, { "\xff\xfe\x00\x00", "UTF-32LE", 4 }, { "\xfe\xff", "UTF-16BE", 2 }, @@ -922,10 +922,10 @@ as_inf_load_file (GKeyFile *keyfile, gchar * as_inf_get_driver_version (GKeyFile *keyfile, guint64 *timestamp, GError **error) { - _cleanup_date_time_unref_ GDateTime *dt = NULL; - _cleanup_strv_free_ gchar **split = NULL; - _cleanup_strv_free_ gchar **dv_split = NULL; - _cleanup_free_ gchar *driver_ver = NULL; + g_autoptr(GDateTime) dt = NULL; + g_auto(GStrv) split = NULL; + g_auto(GStrv) dv_split = NULL; + g_autofree gchar *driver_ver = NULL; /* get the release date and the version in case there's no metainfo */ driver_ver = g_key_file_get_string (keyfile, "Version", "DriverVer", NULL); diff --git a/libappstream-glib/as-monitor.c b/libappstream-glib/as-monitor.c index f7b15d1..916c930 100644 --- a/libappstream-glib/as-monitor.c +++ b/libappstream-glib/as-monitor.c @@ -355,8 +355,8 @@ as_monitor_file_changed_cb (GFileMonitor *mon, AsMonitorPrivate *priv = GET_PRIVATE (monitor); const gchar *tmp; gboolean is_temp; - _cleanup_free_ gchar *filename = NULL; - _cleanup_free_ gchar *filename_other = NULL; + g_autofree gchar *filename = NULL; + g_autofree gchar *filename_other = NULL; /* get both filenames */ filename = g_file_get_path (file); @@ -432,16 +432,16 @@ as_monitor_add_directory (AsMonitor *monitor, { AsMonitorPrivate *priv = GET_PRIVATE (monitor); const gchar *tmp; - _cleanup_object_unref_ GFileMonitor *mon = NULL; - _cleanup_object_unref_ GFile *file = NULL; - _cleanup_dir_close_ GDir *dir = NULL; + g_autoptr(GFileMonitor) mon = NULL; + g_autoptr(GFile) file = NULL; + g_autoptr(GDir) dir = NULL; /* find the files already in the directory */ dir = g_dir_open (filename, 0, error); if (dir == NULL) return FALSE; while ((tmp = g_dir_read_name (dir)) != NULL) { - _cleanup_free_ gchar *fn = NULL; + g_autofree gchar *fn = NULL; fn = g_build_filename (filename, tmp, NULL); g_debug ("adding existing file: %s", fn); _g_ptr_array_str_add (priv->files, fn); @@ -480,8 +480,8 @@ as_monitor_add_file (AsMonitor *monitor, GError **error) { AsMonitorPrivate *priv = GET_PRIVATE (monitor); - _cleanup_object_unref_ GFile *file = NULL; - _cleanup_object_unref_ GFileMonitor *mon = NULL; + g_autoptr(GFile) file = NULL; + g_autoptr(GFileMonitor) mon = NULL; /* already watched */ if (_g_ptr_array_str_find (priv->files, filename) != NULL) diff --git a/libappstream-glib/as-node.c b/libappstream-glib/as-node.c index 284341d..d6ea765 100644 --- a/libappstream-glib/as-node.c +++ b/libappstream-glib/as-node.c @@ -185,8 +185,8 @@ as_node_error_quark (void) static void as_node_string_replace (GString *string, const gchar *search, const gchar *replace) { - _cleanup_free_ gchar *tmp = NULL; - _cleanup_strv_free_ gchar **split = NULL; + g_autofree gchar *tmp = NULL; + g_auto(GStrv) split = NULL; /* quick search */ if (g_strstr_len (string->str, -1, search) == NULL) @@ -365,7 +365,7 @@ as_node_to_xml_string (GString *xml, comment = as_node_get_comment (n); if (comment != NULL) { guint i; - _cleanup_strv_free_ gchar **split = NULL; + g_auto(GStrv) split = NULL; /* do not put additional spacing for the root node */ if (depth_offset < g_node_depth ((GNode *) n) && @@ -453,7 +453,7 @@ as_node_reflow_text (const gchar *text, gssize text_len) GString *tmp; guint i; guint newline_count = 0; - _cleanup_strv_free_ gchar **split = NULL; + g_auto(GStrv) split = NULL; /* split the text into lines */ tmp = g_string_sized_new (text_len + 1); @@ -639,7 +639,7 @@ as_node_passthrough_cb (GMarkupParseContext *context, const gchar *existing; const gchar *tmp; gchar *found; - _cleanup_free_ gchar *text = NULL; + g_autofree gchar *text = NULL; /* only keep comments when told to */ if ((helper->flags & AS_NODE_FROM_XML_FLAG_KEEP_COMMENTS) == 0) @@ -669,7 +669,7 @@ as_node_passthrough_cb (GMarkupParseContext *context, if (existing == NULL) { as_node_add_attribute (helper->current, "@comment-tmp", tmp); } else { - _cleanup_free_ gchar *join = NULL; + g_autofree gchar *join = NULL; join = g_strdup_printf ("%s<&>%s", existing, tmp); as_node_add_attribute (helper->current, "@comment-tmp", join); } @@ -695,8 +695,8 @@ as_node_from_xml (const gchar *data, AsNodeToXmlHelper helper; GNode *root = NULL; gboolean ret; - _cleanup_error_free_ GError *error_local = NULL; - _cleanup_markup_parse_context_unref_ GMarkupParseContext *ctx = NULL; + g_autoptr(GError) error_local = NULL; + g_autoptr(GMarkupParseContext) ctx = NULL; const GMarkupParser parser = { as_node_start_element_cb, as_node_end_element_cb, @@ -798,12 +798,12 @@ as_node_from_file (GFile *file, gboolean ret = TRUE; gsize chunk_size = 32 * 1024; gssize len; - _cleanup_free_ gchar *data = NULL; - _cleanup_markup_parse_context_unref_ GMarkupParseContext *ctx = NULL; - _cleanup_object_unref_ GConverter *conv = NULL; - _cleanup_object_unref_ GFileInfo *info = NULL; - _cleanup_object_unref_ GInputStream *file_stream = NULL; - _cleanup_object_unref_ GInputStream *stream_data = NULL; + g_autofree gchar *data = NULL; + g_autoptr(GMarkupParseContext) ctx = NULL; + g_autoptr(GConverter) conv = NULL; + g_autoptr(GFileInfo) info = NULL; + g_autoptr(GInputStream) file_stream = NULL; + g_autoptr(GInputStream) stream_data = NULL; const GMarkupParser parser = { as_node_start_element_cb, as_node_end_element_cb, @@ -1263,7 +1263,7 @@ as_node_add_attribute (GNode *node, void as_node_add_attribute_as_int (GNode *node, const gchar *key, gint value) { - _cleanup_free_ gchar *tmp = g_strdup_printf ("%i", value); + g_autofree gchar *tmp = g_strdup_printf ("%i", value); as_node_add_attribute (node, key, tmp); } @@ -1283,7 +1283,7 @@ as_node_find (GNode *root, const gchar *path) { GNode *node = root; guint i; - _cleanup_strv_free_ gchar **split = NULL; + g_auto(GStrv) split = NULL; g_return_val_if_fail (path != NULL, NULL); @@ -1315,7 +1315,7 @@ as_node_find_with_attribute (GNode *root, const gchar *path, { GNode *node = root; guint i; - _cleanup_strv_free_ gchar **split = NULL; + g_auto(GStrv) split = NULL; g_return_val_if_fail (path != NULL, NULL); @@ -1445,7 +1445,7 @@ as_node_insert_localized (GNode *parent, const gchar *key; const gchar *value; const gchar *value_c; - _cleanup_list_free_ GList *list = NULL; + g_autoptr(GList) list = NULL; g_return_if_fail (name != NULL); @@ -1602,7 +1602,7 @@ as_node_get_localized (const GNode *node, const gchar *key) const gchar * as_node_get_localized_best (const GNode *node, const gchar *key) { - _cleanup_hashtable_unref_ GHashTable *hash = NULL; + g_autoptr(GHashTable) hash = NULL; hash = as_node_get_localized (node, key); if (hash == NULL) return NULL; @@ -1629,7 +1629,7 @@ as_node_denorm_add_to_langs (GHashTable *hash, GList *l; GString *str; const gchar *xml_lang; - _cleanup_list_free_ GList *keys = NULL; + g_autoptr(GList) keys = NULL; keys = g_hash_table_get_keys (hash); for (l = keys; l != NULL; l = l->next) { @@ -1866,8 +1866,8 @@ as_node_get_localized_unwrap (const GNode *node, GError **error) GString *str; const gchar *xml_lang; gboolean is_li_translated = TRUE; - _cleanup_hashtable_unref_ GHashTable *hash = NULL; - _cleanup_list_free_ GList *keys = NULL; + g_autoptr(GHashTable) hash = NULL; + g_autoptr(GList) keys = NULL; g_return_val_if_fail (node != NULL, NULL); diff --git a/libappstream-glib/as-release.c b/libappstream-glib/as-release.c index 2cff6c6..c790651 100644 --- a/libappstream-glib/as-release.c +++ b/libappstream-glib/as-release.c @@ -410,7 +410,7 @@ as_release_node_insert (AsRelease *release, GNode *parent, AsNodeContext *ctx) AS_NODE_INSERT_FLAG_NONE, NULL); if (priv->timestamp > 0) { - _cleanup_free_ gchar *timestamp_str = NULL; + g_autofree gchar *timestamp_str = NULL; timestamp_str = g_strdup_printf ("%" G_GUINT64_FORMAT, priv->timestamp); as_node_add_attribute (n, "timestamp", timestamp_str); @@ -479,7 +479,7 @@ as_release_node_parse (AsRelease *release, GNode *node, /* get optional checksums */ for (n = node->children; n != NULL; n = n->next) { - _cleanup_object_unref_ AsChecksum *csum = NULL; + g_autoptr(AsChecksum) csum = NULL; if (as_node_get_tag (n) != AS_TAG_CHECKSUM) continue; csum = as_checksum_new (); diff --git a/libappstream-glib/as-screenshot.c b/libappstream-glib/as-screenshot.c index e43c767..7d4cc5d 100644 --- a/libappstream-glib/as-screenshot.c +++ b/libappstream-glib/as-screenshot.c @@ -401,7 +401,7 @@ as_screenshot_node_parse (AsScreenshot *screenshot, GNode *node, const gchar *tmp; guint size; gint priority; - _cleanup_hashtable_unref_ GHashTable *captions = NULL; + g_autoptr(GHashTable) captions = NULL; tmp = as_node_get_attribute (node, "type"); if (tmp != NULL) { @@ -415,7 +415,7 @@ as_screenshot_node_parse (AsScreenshot *screenshot, GNode *node, /* add captions */ captions = as_node_get_localized (node, "caption"); if (captions != NULL) { - _cleanup_list_free_ GList *keys = NULL; + g_autoptr(GList) keys = NULL; keys = g_hash_table_get_keys (captions); for (l = keys; l != NULL; l = l->next) { tmp = l->data; @@ -443,7 +443,7 @@ as_screenshot_node_parse (AsScreenshot *screenshot, GNode *node, /* add images */ for (c = node->children; c != NULL; c = c->next) { - _cleanup_object_unref_ AsImage *image = NULL; + g_autoptr(AsImage) image = NULL; if (as_node_get_tag (c) != AS_TAG_IMAGE) continue; image = as_image_new (); @@ -485,7 +485,7 @@ as_screenshot_node_parse_dep11 (AsScreenshot *ss, GNode *node, continue; } if (g_strcmp0 (tmp, "source-image") == 0) { - _cleanup_object_unref_ AsImage *im = as_image_new (); + g_autoptr(AsImage) im = as_image_new (); as_image_set_kind (im, AS_IMAGE_KIND_SOURCE); if (!as_image_node_parse_dep11 (im, n, ctx, error)) return FALSE; @@ -494,7 +494,7 @@ as_screenshot_node_parse_dep11 (AsScreenshot *ss, GNode *node, } if (g_strcmp0 (tmp, "thumbnails") == 0) { for (c = n->children; c != NULL; c = c->next) { - _cleanup_object_unref_ AsImage *im = as_image_new (); + g_autoptr(AsImage) im = as_image_new (); as_image_set_kind (im, AS_IMAGE_KIND_THUMBNAIL); if (!as_image_node_parse_dep11 (im, c, ctx, error)) return FALSE; diff --git a/libappstream-glib/as-self-test.c b/libappstream-glib/as-self-test.c index 2e7e32c..3a69ae6 100644 --- a/libappstream-glib/as-self-test.c +++ b/libappstream-glib/as-self-test.c @@ -50,7 +50,7 @@ static gboolean as_test_compare_lines (const gchar *txt1, const gchar *txt2, GError **error) { - _cleanup_free_ gchar *output = NULL; + g_autofree gchar *output = NULL; /* exactly the same */ if (g_strcmp0 (txt1, txt2) == 0) @@ -77,7 +77,7 @@ static gchar * as_test_get_filename (const gchar *filename) { _cleanup_free_libc_ gchar *tmp = NULL; - _cleanup_free_ gchar *path = NULL; + g_autofree gchar *path = NULL; path = g_build_filename (TESTDATADIR, filename, NULL); /* glibc allocates a buffer */ @@ -142,12 +142,12 @@ as_test_monitor_dir_func (void) guint cnt_added = 0; guint cnt_removed = 0; guint cnt_changed = 0; - _cleanup_object_unref_ AsMonitor *mon = NULL; - _cleanup_error_free_ GError *error = NULL; + g_autoptr(AsMonitor) mon = NULL; + g_autoptr(GError) error = NULL; const gchar *tmpdir = "/tmp/monitor-test/usr/share/app-info/xmls"; - _cleanup_free_ gchar *tmpfile = NULL; - _cleanup_free_ gchar *tmpfile_new = NULL; - _cleanup_free_ gchar *cmd_touch = NULL; + g_autofree gchar *tmpfile = NULL; + g_autofree gchar *tmpfile_new = NULL; + g_autofree gchar *cmd_touch = NULL; tmpfile = g_build_filename (tmpdir, "test.txt", NULL); tmpfile_new = g_build_filename (tmpdir, "newtest.txt", NULL); @@ -241,11 +241,11 @@ as_test_monitor_file_func (void) guint cnt_added = 0; guint cnt_removed = 0; guint cnt_changed = 0; - _cleanup_object_unref_ AsMonitor *mon = NULL; - _cleanup_error_free_ GError *error = NULL; + g_autoptr(AsMonitor) mon = NULL; + g_autoptr(GError) error = NULL; const gchar *tmpfile = "/tmp/one.txt"; const gchar *tmpfile_new = "/tmp/two.txt"; - _cleanup_free_ gchar *cmd_touch = NULL; + g_autofree gchar *cmd_touch = NULL; g_unlink (tmpfile); g_unlink (tmpfile_new); @@ -349,8 +349,8 @@ as_test_release_func (void) GString *xml; const gchar *src = "<release version=\"0.1.2\" timestamp=\"123\"/>"; gboolean ret; - _cleanup_free_ AsNodeContext *ctx = NULL; - _cleanup_object_unref_ AsRelease *release = NULL; + g_autofree AsNodeContext *ctx = NULL; + g_autoptr(AsRelease) release = NULL; release = as_release_new (); @@ -391,8 +391,8 @@ as_test_provide_func (void) GString *xml; const gchar *src = "<binary>/usr/bin/gnome-shell</binary>"; gboolean ret; - _cleanup_free_ AsNodeContext *ctx = NULL; - _cleanup_object_unref_ AsProvide *provide = NULL; + g_autofree AsNodeContext *ctx = NULL; + g_autoptr(AsProvide) provide = NULL; provide = as_provide_new (); @@ -442,8 +442,8 @@ as_test_release_appstream_func (void) "<description><p>This is a new release</p><ul><li>Point</li></ul></description>\n" "<description xml:lang=\"pl\"><p>Oprogramowanie</p></description>\n" "</release>\n"; - _cleanup_free_ AsNodeContext *ctx = NULL; - _cleanup_object_unref_ AsRelease *release = NULL; + g_autofree AsNodeContext *ctx = NULL; + g_autoptr(AsRelease) release = NULL; release = as_release_new (); @@ -514,8 +514,8 @@ as_test_release_appdata_func (void) "<p xml:lang=\"pl\">Oprogramowanie</p>\n" "</description>\n" "</release>\n"; - _cleanup_free_ AsNodeContext *ctx = NULL; - _cleanup_object_unref_ AsRelease *release = NULL; + g_autofree AsNodeContext *ctx = NULL; + g_autoptr(AsRelease) release = NULL; release = as_release_new (); @@ -573,8 +573,8 @@ static void as_test_image_resize_filename (AsTestResize rz, const gchar *in, const gchar *out) { gboolean ret; - _cleanup_object_unref_ GdkPixbuf *pb = NULL; - _cleanup_object_unref_ GdkPixbuf *pb2 = NULL; + g_autoptr(GdkPixbuf) pb = NULL; + g_autoptr(GdkPixbuf) pb2 = NULL; pb = gdk_pixbuf_new_from_file (in, NULL); g_assert (pb != NULL); @@ -630,14 +630,14 @@ static void as_test_image_alpha_func (void) { gboolean ret; - _cleanup_error_free_ GError *error = NULL; - _cleanup_free_ gchar *fn_both = NULL; - _cleanup_free_ gchar *fn_horiz = NULL; - _cleanup_free_ gchar *fn_internal1 = NULL; - _cleanup_free_ gchar *fn_internal2 = NULL; - _cleanup_free_ gchar *fn_none = NULL; - _cleanup_free_ gchar *fn_vert = NULL; - _cleanup_object_unref_ AsImage *im = NULL; + g_autoptr(GError) error = NULL; + g_autofree gchar *fn_both = NULL; + g_autofree gchar *fn_horiz = NULL; + g_autofree gchar *fn_internal1 = NULL; + g_autofree gchar *fn_internal2 = NULL; + g_autofree gchar *fn_none = NULL; + g_autofree gchar *fn_vert = NULL; + g_autoptr(AsImage) im = NULL; /* horiz */ fn_horiz = as_test_get_filename ("alpha-horiz.png"); @@ -697,8 +697,8 @@ as_test_image_resize_func (void) { GError *error = NULL; const gchar *tmp; - _cleanup_dir_close_ GDir *dir = NULL; - _cleanup_free_ gchar *output_dir = NULL; + g_autoptr(GDir) dir = NULL; + g_autofree gchar *output_dir = NULL; /* only do this test if an "output" directory exists */ output_dir = g_build_filename (TESTDATADIR, "output", NULL); @@ -711,14 +711,14 @@ as_test_image_resize_func (void) g_assert (dir != NULL); while ((tmp = g_dir_read_name (dir)) != NULL) { guint i; - _cleanup_free_ gchar *path = NULL; + g_autofree gchar *path = NULL; if (!g_str_has_prefix (tmp, "ss-")) continue; path = g_build_filename (TESTDATADIR, tmp, NULL); for (i = 0; i < AS_TEST_RESIZE_LAST; i++) { - _cleanup_free_ gchar *new_path = NULL; + g_autofree gchar *new_path = NULL; _cleanup_string_free_ GString *basename = NULL; basename = g_string_new (tmp); @@ -740,10 +740,10 @@ as_test_icon_func (void) GString *xml; const gchar *src = "<icon type=\"cached\">app.png</icon>"; gboolean ret; - _cleanup_free_ AsNodeContext *ctx = NULL; - _cleanup_free_ gchar *prefix = NULL; - _cleanup_object_unref_ AsIcon *icon = NULL; - _cleanup_object_unref_ GdkPixbuf *pixbuf = NULL; + g_autofree AsNodeContext *ctx = NULL; + g_autofree gchar *prefix = NULL; + g_autoptr(AsIcon) icon = NULL; + g_autoptr(GdkPixbuf) pixbuf = NULL; icon = as_icon_new (); @@ -803,8 +803,8 @@ as_test_checksum_func (void) GString *xml; const gchar *src = "<checksum filename=\"fn.cab\" target=\"container\" type=\"sha1\">12345</checksum>"; gboolean ret; - _cleanup_free_ AsNodeContext *ctx = NULL; - _cleanup_object_unref_ AsChecksum *csum = NULL; + g_autofree AsNodeContext *ctx = NULL; + g_autoptr(AsChecksum) csum = NULL; /* helpers */ g_assert_cmpint (as_checksum_target_from_string ("container"), ==, AS_CHECKSUM_TARGET_CONTAINER); @@ -900,9 +900,9 @@ as_test_icon_embedded_func (void) "</filecontent>" "</icon>"; gboolean ret; - _cleanup_free_ AsNodeContext *ctx = NULL; - _cleanup_object_unref_ AsIcon *icon = NULL; - _cleanup_object_unref_ GdkPixbuf *pixbuf = NULL; + g_autofree AsNodeContext *ctx = NULL; + g_autoptr(AsIcon) icon = NULL; + g_autoptr(GdkPixbuf) pixbuf = NULL; icon = as_icon_new (); @@ -963,10 +963,10 @@ as_test_image_func (void) "<image type=\"thumbnail\" height=\"12\" width=\"34\">" "http://www.hughsie.com/a.jpg</image>"; gboolean ret; - _cleanup_free_ AsNodeContext *ctx = NULL; - _cleanup_free_ gchar *filename = NULL; - _cleanup_object_unref_ AsImage *image = NULL; - _cleanup_object_unref_ GdkPixbuf *pixbuf = NULL; + g_autofree AsNodeContext *ctx = NULL; + g_autofree gchar *filename = NULL; + g_autoptr(AsImage) image = NULL; + g_autoptr(GdkPixbuf) pixbuf = NULL; image = as_image_new (); @@ -1036,8 +1036,8 @@ as_test_bundle_func (void) const gchar *src = "<bundle type=\"limba\">gnome-3-16</bundle>"; gboolean ret; - _cleanup_free_ AsNodeContext *ctx = NULL; - _cleanup_object_unref_ AsBundle *bundle = NULL; + g_autofree AsNodeContext *ctx = NULL; + g_autoptr(AsBundle) bundle = NULL; bundle = as_bundle_new (); @@ -1085,8 +1085,8 @@ as_test_screenshot_func (void) "<image type=\"thumbnail\" height=\"100\" width=\"100\">http://2.png</image>\n" "</screenshot>\n"; gboolean ret; - _cleanup_free_ AsNodeContext *ctx = NULL; - _cleanup_object_unref_ AsScreenshot *screenshot = NULL; + g_autofree AsNodeContext *ctx = NULL; + g_autoptr(AsScreenshot) screenshot = NULL; screenshot = as_screenshot_new (); @@ -1208,8 +1208,8 @@ as_test_app_func (void) "<value key=\"SomethingRandom\"/>\n" "</metadata>\n" "</component>\n"; - _cleanup_free_ AsNodeContext *ctx = NULL; - _cleanup_object_unref_ AsApp *app = NULL; + g_autofree AsNodeContext *ctx = NULL; + g_autoptr(AsApp) app = NULL; app = as_app_new (); @@ -1308,7 +1308,7 @@ as_test_app_validate_check (GPtrArray *array, guint i; for (i = 0; i < array->len; i++) { - _cleanup_free_ gchar *message_no_data = NULL; + g_autofree gchar *message_no_data = NULL; problem = g_ptr_array_index (array, i); if (as_problem_get_kind (problem) != kind) continue; @@ -1341,8 +1341,8 @@ as_test_app_validate_appdata_good_func (void) GPtrArray *screenshots; gboolean ret; guint i; - _cleanup_free_ gchar *filename = NULL; - _cleanup_object_unref_ AsApp *app = NULL; + g_autofree gchar *filename = NULL; + g_autoptr(AsApp) app = NULL; /* open file */ app = as_app_new (); @@ -1395,8 +1395,8 @@ as_test_app_validate_metainfo_good_func (void) GPtrArray *probs; gboolean ret; guint i; - _cleanup_free_ gchar *filename = NULL; - _cleanup_object_unref_ AsApp *app = NULL; + g_autofree gchar *filename = NULL; + g_autoptr(AsApp) app = NULL; /* open file */ app = as_app_new (); @@ -1437,8 +1437,8 @@ as_test_app_validate_intltool_func (void) GPtrArray *probs; gboolean ret; guint i; - _cleanup_free_ gchar *filename = NULL; - _cleanup_object_unref_ AsApp *app = NULL; + g_autofree gchar *filename = NULL; + g_autoptr(AsApp) app = NULL; /* open file */ app = as_app_new (); @@ -1468,8 +1468,8 @@ as_test_app_translated_func (void) { GError *error = NULL; gboolean ret; - _cleanup_free_ gchar *filename = NULL; - _cleanup_object_unref_ AsApp *app = NULL; + g_autofree gchar *filename = NULL; + g_autoptr(AsApp) app = NULL; /* open file */ app = as_app_new (); @@ -1491,9 +1491,9 @@ as_test_app_validate_file_bad_func (void) GError *error = NULL; gboolean ret; guint i; - _cleanup_free_ gchar *filename = NULL; - _cleanup_object_unref_ AsApp *app = NULL; - _cleanup_ptrarray_unref_ GPtrArray *probs = NULL; + g_autofree gchar *filename = NULL; + g_autoptr(AsApp) app = NULL; + g_autoptr(GPtrArray) probs = NULL; /* open file */ app = as_app_new (); @@ -1572,9 +1572,9 @@ as_test_app_validate_meta_bad_func (void) GError *error = NULL; gboolean ret; guint i; - _cleanup_free_ gchar *filename = NULL; - _cleanup_object_unref_ AsApp *app = NULL; - _cleanup_ptrarray_unref_ GPtrArray *probs = NULL; + g_autofree gchar *filename = NULL; + g_autoptr(AsApp) app = NULL; + g_autoptr(GPtrArray) probs = NULL; /* open file */ app = as_app_new (); @@ -1614,9 +1614,9 @@ as_test_store_local_app_install_func (void) AsIcon *ic; GError *error = NULL; gboolean ret; - _cleanup_free_ gchar *filename = NULL; - _cleanup_free_ gchar *source_file = NULL; - _cleanup_object_unref_ AsStore *store = NULL; + g_autofree gchar *filename = NULL; + g_autofree gchar *source_file = NULL; + g_autoptr(AsStore) store = NULL; /* open test store */ store = as_store_new (); @@ -1659,8 +1659,8 @@ as_test_store_local_appdata_func (void) AsApp *app; GError *error = NULL; gboolean ret; - _cleanup_free_ gchar *filename = NULL; - _cleanup_object_unref_ AsStore *store = NULL; + g_autofree gchar *filename = NULL; + g_autoptr(AsStore) store = NULL; /* this are the warnings expected */ g_test_expect_message (G_LOG_DOMAIN, @@ -1688,10 +1688,10 @@ as_test_store_validate_func (void) { GError *error = NULL; gboolean ret; - _cleanup_free_ gchar *filename = NULL; - _cleanup_object_unref_ AsStore *store = NULL; - _cleanup_object_unref_ GFile *file = NULL; - _cleanup_ptrarray_unref_ GPtrArray *probs = NULL; + g_autofree gchar *filename = NULL; + g_autoptr(AsStore) store = NULL; + g_autoptr(GFile) file = NULL; + g_autoptr(GPtrArray) probs = NULL; /* open file */ store = as_store_new (); @@ -1726,8 +1726,8 @@ as_test_app_validate_style_func (void) AsProblem *problem; GError *error = NULL; guint i; - _cleanup_object_unref_ AsApp *app = NULL; - _cleanup_ptrarray_unref_ GPtrArray *probs = NULL; + g_autoptr(AsApp) app = NULL; + g_autoptr(GPtrArray) probs = NULL; app = as_app_new (); as_app_add_url (app, AS_URL_KIND_UNKNOWN, "dave.com"); @@ -1778,8 +1778,8 @@ as_test_app_parse_file_desktop_func (void) AsIcon *ic; GError *error = NULL; gboolean ret; - _cleanup_free_ gchar *filename = NULL; - _cleanup_object_unref_ AsApp *app = NULL; + g_autofree gchar *filename = NULL; + g_autoptr(AsApp) app = NULL; /* create an AsApp from a desktop file */ app = as_app_new (); @@ -1843,8 +1843,8 @@ as_test_app_parse_file_inf_func (void) GError *error = NULL; GPtrArray *releases; gboolean ret; - _cleanup_free_ gchar *filename = NULL; - _cleanup_object_unref_ AsApp *app = NULL; + g_autofree gchar *filename = NULL; + g_autoptr(AsApp) app = NULL; /* create an AsApp from a desktop file */ app = as_app_new (); @@ -1894,8 +1894,8 @@ as_test_app_no_markup_func (void) "<id>org.gnome.Software.desktop</id>\n" "<description>Software is awesome:\n\n * Bada\n * Boom!</description>\n" "</component>\n"; - _cleanup_free_ AsNodeContext *ctx = NULL; - _cleanup_object_unref_ AsApp *app = NULL; + g_autofree AsNodeContext *ctx = NULL; + g_autoptr(AsApp) app = NULL; app = as_app_new (); @@ -1964,7 +1964,7 @@ as_test_node_reflow_text_func (void) static void as_test_node_sort_func (void) { - _cleanup_error_free_ GError *error = NULL; + g_autoptr(GError) error = NULL; _cleanup_node_unref_ GNode *root = NULL; _cleanup_string_free_ GString *str = NULL; @@ -2246,7 +2246,7 @@ as_test_node_localized_wrap_func (void) " <li xml:lang=\"en_GB\">Hi</li>" " </ul>" "</description>"; - _cleanup_hashtable_unref_ GHashTable *hash = NULL; + g_autoptr(GHashTable) hash = NULL; _cleanup_node_unref_ GNode *root = NULL; root = as_node_from_xml (xml, 0, &error); @@ -2303,7 +2303,7 @@ as_test_node_localized_wrap2_func (void) " <li>Secondski</li>" " </ul>" "</description>"; - _cleanup_hashtable_unref_ GHashTable *hash = NULL; + g_autoptr(GHashTable) hash = NULL; _cleanup_node_unref_ GNode *root = NULL; root = as_node_from_xml (xml, 0, &error); @@ -2333,10 +2333,10 @@ as_test_app_subsume_func (void) { AsIcon *ic; GList *list; - _cleanup_object_unref_ AsApp *app = NULL; - _cleanup_object_unref_ AsApp *donor = NULL; - _cleanup_object_unref_ AsIcon *icon = NULL; - _cleanup_object_unref_ AsScreenshot *ss = NULL; + g_autoptr(AsApp) app = NULL; + g_autoptr(AsApp) donor = NULL; + g_autoptr(AsIcon) icon = NULL; + g_autoptr(AsScreenshot) ss = NULL; donor = as_app_new (); icon = as_icon_new (); @@ -2395,7 +2395,7 @@ as_test_app_search_func (void) const gchar *all[] = { "gnome", "install", "software", NULL }; const gchar *none[] = { "gnome", "xxx", "software", NULL }; const gchar *mime[] = { "vnd", "oasis", "opendocument","text", NULL }; - _cleanup_object_unref_ AsApp *app = NULL; + g_autoptr(AsApp) app = NULL; app = as_app_new (); as_app_set_name (app, NULL, "GNOME Software"); @@ -2426,8 +2426,8 @@ as_test_store_embedded_func (void) AsApp *app; AsIcon *icon; gboolean ret; - _cleanup_error_free_ GError *error = NULL; - _cleanup_object_unref_ AsStore *store = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(AsStore) store = NULL; _cleanup_string_free_ GString *xml = NULL; const gchar *xml_src = "<components version=\"0.6\" origin=\"origin\">" @@ -2530,8 +2530,8 @@ as_test_store_auto_reload_dir_func (void) AsApp *app; gboolean ret; guint cnt = 0; - _cleanup_error_free_ GError *error = NULL; - _cleanup_object_unref_ AsStore *store = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(AsStore) store = NULL; /* add this file to a store */ store = as_store_new (); @@ -2584,9 +2584,9 @@ as_test_store_auto_reload_file_func (void) AsRelease *rel; gboolean ret; guint cnt = 0; - _cleanup_error_free_ GError *error = NULL; - _cleanup_object_unref_ AsStore *store = NULL; - _cleanup_object_unref_ GFile *file = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(AsStore) store = NULL; + g_autoptr(GFile) file = NULL; /* set initial file */ ret = g_file_set_contents ("/tmp/foo.xml", @@ -2668,11 +2668,11 @@ as_test_store_demote_func (void) AsApp *app; GError *error = NULL; gboolean ret; - _cleanup_free_ gchar *filename1 = NULL; - _cleanup_free_ gchar *filename2 = NULL; - _cleanup_object_unref_ AsApp *app_appdata = NULL; - _cleanup_object_unref_ AsApp *app_desktop = NULL; - _cleanup_object_unref_ AsStore *store = NULL; + g_autofree gchar *filename1 = NULL; + g_autofree gchar *filename2 = NULL; + g_autoptr(AsApp) app_appdata = NULL; + g_autoptr(AsApp) app_desktop = NULL; + g_autoptr(AsStore) store = NULL; _cleanup_string_free_ GString *xml = NULL; /* load example desktop file */ @@ -2717,11 +2717,11 @@ static void as_test_store_merges_func (void) { AsApp *app_tmp; - _cleanup_object_unref_ AsApp *app_appdata = NULL; - _cleanup_object_unref_ AsApp *app_appinfo = NULL; - _cleanup_object_unref_ AsApp *app_desktop = NULL; - _cleanup_object_unref_ AsStore *store_all = NULL; - _cleanup_object_unref_ AsStore *store_desktop_appdata = NULL; + g_autoptr(AsApp) app_appdata = NULL; + g_autoptr(AsApp) app_appinfo = NULL; + g_autoptr(AsApp) app_desktop = NULL; + g_autoptr(AsStore) store_all = NULL; + g_autoptr(AsStore) store_desktop_appdata = NULL; /* test desktop + appdata */ store_desktop_appdata = as_store_new (); @@ -2785,10 +2785,10 @@ static void as_test_store_merges_local_func (void) { AsApp *app_tmp; - _cleanup_object_unref_ AsApp *app_appdata = NULL; - _cleanup_object_unref_ AsApp *app_appinfo = NULL; - _cleanup_object_unref_ AsApp *app_desktop = NULL; - _cleanup_object_unref_ AsStore *store = NULL; + g_autoptr(AsApp) app_appdata = NULL; + g_autoptr(AsApp) app_appinfo = NULL; + g_autoptr(AsApp) app_desktop = NULL; + g_autoptr(AsStore) store = NULL; /* test desktop + appdata + appstream */ store = as_store_new (); @@ -2839,8 +2839,8 @@ static void as_test_store_empty_func (void) { gboolean ret; - _cleanup_error_free_ GError *error = NULL; - _cleanup_object_unref_ AsStore *store = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(AsStore) store = NULL; store = as_store_new (); ret = as_store_from_xml (store, "", NULL, &error); @@ -2853,7 +2853,7 @@ as_test_store_func (void) { AsApp *app; GString *xml; - _cleanup_object_unref_ AsStore *store = NULL; + g_autoptr(AsStore) store = NULL; /* create a store and add a single app */ store = as_store_new (); @@ -2919,8 +2919,8 @@ as_test_store_provides_func (void) { AsApp *app; gboolean ret; - _cleanup_error_free_ GError *error = NULL; - _cleanup_object_unref_ AsStore *store = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(AsStore) store = NULL; /* create a store and add a single app */ store = as_store_new (); @@ -3068,7 +3068,7 @@ as_test_store_addons_func (void) "<id>eclipse.desktop</id>" "</component>" "</components>"; - _cleanup_object_unref_ AsStore *store = NULL; + g_autoptr(AsStore) store = NULL; _cleanup_string_free_ GString *str = NULL; /* load a file to the store */ @@ -3119,8 +3119,8 @@ as_test_node_no_dup_c_func (void) "<name>Krita</name>" "<name xml:lang=\"pl\">Krita</name>" "</component>"; - _cleanup_free_ AsNodeContext *ctx = NULL; - _cleanup_object_unref_ AsApp *app = NULL; + g_autofree AsNodeContext *ctx = NULL; + g_autoptr(AsApp) app = NULL; /* to object */ app = as_app_new (); @@ -3159,9 +3159,9 @@ as_test_store_origin_func (void) AsApp *app; GError *error = NULL; gboolean ret; - _cleanup_free_ gchar *filename = NULL; - _cleanup_object_unref_ AsStore *store = NULL; - _cleanup_object_unref_ GFile *file = NULL; + g_autofree gchar *filename = NULL; + g_autoptr(AsStore) store = NULL; + g_autoptr(GFile) file = NULL; /* load a file to the store */ store = as_store_new (); @@ -3189,15 +3189,15 @@ as_test_store_speed_appstream_func (void) gboolean ret; guint i; guint loops = 10; - _cleanup_free_ gchar *filename = NULL; - _cleanup_object_unref_ GFile *file = NULL; - _cleanup_timer_destroy_ GTimer *timer = NULL; + g_autofree gchar *filename = NULL; + g_autoptr(GFile) file = NULL; + g_autoptr(GTimer) timer = NULL; filename = as_test_get_filename ("example-v04.xml.gz"); file = g_file_new_for_path (filename); timer = g_timer_new (); for (i = 0; i < loops; i++) { - _cleanup_object_unref_ AsStore *store = NULL; + g_autoptr(AsStore) store = NULL; store = as_store_new (); ret = as_store_from_file (store, file, NULL, NULL, &error); g_assert_no_error (error); @@ -3216,13 +3216,13 @@ as_test_store_speed_appdata_func (void) gboolean ret; guint i; guint loops = 10; - _cleanup_free_ gchar *filename = NULL; - _cleanup_timer_destroy_ GTimer *timer = NULL; + g_autofree gchar *filename = NULL; + g_autoptr(GTimer) timer = NULL; filename = as_test_get_filename ("."); timer = g_timer_new (); for (i = 0; i < loops; i++) { - _cleanup_object_unref_ AsStore *store = NULL; + g_autoptr(AsStore) store = NULL; store = as_store_new (); as_store_set_destdir (store, filename); g_test_expect_message (G_LOG_DOMAIN, @@ -3243,13 +3243,13 @@ as_test_store_speed_desktop_func (void) gboolean ret; guint i; guint loops = 10; - _cleanup_free_ gchar *filename = NULL; - _cleanup_timer_destroy_ GTimer *timer = NULL; + g_autofree gchar *filename = NULL; + g_autoptr(GTimer) timer = NULL; filename = as_test_get_filename ("."); timer = g_timer_new (); for (i = 0; i < loops; i++) { - _cleanup_object_unref_ AsStore *store = NULL; + g_autoptr(AsStore) store = NULL; store = as_store_new (); as_store_set_destdir (store, filename); ret = as_store_load (store, AS_STORE_LOAD_FLAG_DESKTOP, NULL, &error); @@ -3263,7 +3263,7 @@ as_test_store_speed_desktop_func (void) static void as_test_utils_guid_func (void) { - _cleanup_free_ gchar *guid = NULL; + g_autofree gchar *guid = NULL; /* invalid */ g_assert (!as_utils_guid_is_valid (NULL)); @@ -3285,7 +3285,7 @@ as_test_utils_icons_func (void) { gchar *tmp; GError *error = NULL; - _cleanup_free_ gchar *destdir = NULL; + g_autofree gchar *destdir = NULL; destdir = as_test_get_filename ("."); @@ -3527,7 +3527,7 @@ as_test_store_app_install_func (void) { GError *error = NULL; gboolean ret; - _cleanup_object_unref_ AsStore *store = NULL; + g_autoptr(AsStore) store = NULL; store = as_store_new (); ret = as_store_load (store, @@ -3559,7 +3559,7 @@ as_test_store_metadata_func (void) "</metadata>" "</component>" "</components>"; - _cleanup_object_unref_ AsStore *store = NULL; + g_autoptr(AsStore) store = NULL; store = as_store_new (); ret = as_store_from_xml (store, xml, NULL, &error); @@ -3577,15 +3577,15 @@ as_test_store_metadata_index_func (void) GPtrArray *apps; const guint repeats = 10000; guint i; - _cleanup_object_unref_ AsStore *store = NULL; - _cleanup_timer_destroy_ GTimer *timer = NULL; + g_autoptr(AsStore) store = NULL; + g_autoptr(GTimer) timer = NULL; /* create lots of applications in the store */ store = as_store_new (); as_store_add_metadata_index (store, "X-CacheID"); for (i = 0; i < repeats; i++) { - _cleanup_free_ gchar *id = g_strdup_printf ("app-%05i", i); - _cleanup_object_unref_ AsApp *app = as_app_new (); + g_autofree gchar *id = g_strdup_printf ("app-%05i", i); + g_autoptr(AsApp) app = as_app_new (); as_app_set_id (app, id); as_app_add_metadata (app, "X-CacheID", "dave.i386"); as_app_add_metadata (app, "baz", "dave"); @@ -3613,8 +3613,8 @@ as_test_yaml_func (void) GError *error = NULL; GString *str; const gchar *expected; - _cleanup_free_ gchar *filename = NULL; - _cleanup_object_unref_ GFile *file = NULL; + g_autofree gchar *filename = NULL; + g_autoptr(GFile) file = NULL; /* simple header */ node = as_yaml_from_data ( @@ -3722,10 +3722,10 @@ as_test_store_yaml_func (void) AsApp *app; GError *error = NULL; gboolean ret; - _cleanup_free_ gchar *filename = NULL; - _cleanup_free_ gchar *icon_root = NULL; - _cleanup_object_unref_ AsStore *store = NULL; - _cleanup_object_unref_ GFile *file = NULL; + g_autofree gchar *filename = NULL; + g_autofree gchar *icon_root = NULL; + g_autoptr(AsStore) store = NULL; + g_autoptr(GFile) file = NULL; _cleanup_string_free_ GString *str = NULL; const gchar *xml = "<components version=\"0.6\" origin=\"aequorea\">\n" @@ -3788,16 +3788,16 @@ as_test_store_speed_yaml_func (void) gboolean ret; guint i; guint loops = 10; - _cleanup_free_ gchar *filename = NULL; - _cleanup_object_unref_ GFile *file = NULL; - _cleanup_timer_destroy_ GTimer *timer = NULL; + g_autofree gchar *filename = NULL; + g_autoptr(GFile) file = NULL; + g_autoptr(GTimer) timer = NULL; filename = as_test_get_filename ("example-v06.yml.gz"); g_assert (filename != NULL); file = g_file_new_for_path (filename); timer = g_timer_new (); for (i = 0; i < loops; i++) { - _cleanup_object_unref_ AsStore *store = NULL; + g_autoptr(AsStore) store = NULL; store = as_store_new (); ret = as_store_from_file (store, file, NULL, NULL, &error); g_assert_no_error (error); @@ -3848,9 +3848,9 @@ as_test_inf_func (void) gboolean ret; gchar *tmp; guint64 ts; - _cleanup_dir_close_ GDir *dir = NULL; - _cleanup_free_ gchar *filename = NULL; - _cleanup_free_ gchar *infs = NULL; + g_autoptr(GDir) dir = NULL; + g_autofree gchar *filename = NULL; + g_autofree gchar *infs = NULL; /* case insensitive */ kf = g_key_file_new (); @@ -4124,7 +4124,7 @@ as_test_inf_func (void) if (infs != NULL) { dir = g_dir_open (infs, 0, NULL); while ((data = g_dir_read_name (dir)) != NULL) { - _cleanup_free_ gchar *path = NULL; + g_autofree gchar *path = NULL; path = g_build_filename (infs, data, NULL); kf = g_key_file_new (); ret = as_inf_load_file (kf, path, @@ -4151,10 +4151,10 @@ as_test_utils_install_filename_func (void) { gboolean ret; GError *error = NULL; - _cleanup_free_ gchar *filename1 = NULL; - _cleanup_free_ gchar *filename2 = NULL; - _cleanup_free_ gchar *filename3 = NULL; - _cleanup_free_ gchar *filename4 = NULL; + g_autofree gchar *filename1 = NULL; + g_autofree gchar *filename2 = NULL; + g_autofree gchar *filename3 = NULL; + g_autofree gchar *filename4 = NULL; /* appdata to shared */ filename1 = as_test_get_filename ("broken.appdata.xml"); diff --git a/libappstream-glib/as-store.c b/libappstream-glib/as-store.c index 0a0f5b0..1ad5987 100644 --- a/libappstream-glib/as-store.c +++ b/libappstream-glib/as-store.c @@ -861,8 +861,8 @@ as_store_from_root (AsStore *store, GNode *apps; GNode *n; const gchar *tmp; - _cleanup_free_ AsNodeContext *ctx = NULL; - _cleanup_free_ gchar *icon_path = NULL; + g_autofree AsNodeContext *ctx = NULL; + g_autofree gchar *icon_path = NULL; _cleanup_uninhibit_ guint32 *tok = NULL; g_return_val_if_fail (AS_IS_STORE (store), FALSE); @@ -908,8 +908,8 @@ as_store_from_root (AsStore *store, } ctx = as_node_context_new (); for (n = apps->children; n != NULL; n = n->next) { - _cleanup_error_free_ GError *error_local = NULL; - _cleanup_object_unref_ AsApp *app = NULL; + g_autoptr(GError) error_local = NULL; + g_autoptr(AsApp) app = NULL; if (as_node_get_tag (n) != AS_TAG_COMPONENT) continue; @@ -966,8 +966,8 @@ as_store_load_yaml_file (AsStore *store, GNode *app_n; GNode *n; const gchar *tmp; - _cleanup_free_ AsNodeContext *ctx = NULL; - _cleanup_free_ gchar *icon_path = NULL; + g_autofree AsNodeContext *ctx = NULL; + g_autofree gchar *icon_path = NULL; _cleanup_yaml_unref_ GNode *root = NULL; _cleanup_uninhibit_ guint32 *tok = NULL; @@ -1005,7 +1005,7 @@ as_store_load_yaml_file (AsStore *store, /* parse applications */ ctx = as_node_context_new (); for (app_n = root->children->next; app_n != NULL; app_n = app_n->next) { - _cleanup_object_unref_ AsApp *app = NULL; + g_autoptr(AsApp) app = NULL; if (app_n->children == NULL) continue; app = as_app_new (); @@ -1036,7 +1036,7 @@ as_store_remove_by_source_file (AsStore *store, const gchar *filename) GPtrArray *apps; guint i; const gchar *tmp; - _cleanup_ptrarray_unref_ GPtrArray *ids = NULL; + g_autoptr(GPtrArray) ids = NULL; /* find any applications in the store with this source file */ ids = g_ptr_array_new_with_free_func (g_free); @@ -1071,8 +1071,8 @@ as_store_monitor_changed_cb (AsMonitor *monitor, /* reload, or emit a signal */ if (priv->watch_flags & AS_STORE_WATCH_FLAG_ADDED) { - _cleanup_error_free_ GError *error = NULL; - _cleanup_object_unref_ GFile *file = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(GFile) file = NULL; _cleanup_uninhibit_ guint32 *tok = NULL; tok = as_store_changed_inhibit (store); as_store_remove_by_source_file (store, filename); @@ -1096,8 +1096,8 @@ as_store_monitor_added_cb (AsMonitor *monitor, /* reload, or emit a signal */ if (priv->watch_flags & AS_STORE_WATCH_FLAG_ADDED) { - _cleanup_error_free_ GError *error = NULL; - _cleanup_object_unref_ GFile *file = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(GFile) file = NULL; g_debug ("scanning %s", filename); file = g_file_new_for_path (filename); if (!as_store_from_file (store, file, NULL, NULL, &error)) @@ -1151,8 +1151,8 @@ as_store_from_file (AsStore *store, GError **error) { AsStorePrivate *priv = GET_PRIVATE (store); - _cleanup_free_ gchar *filename = NULL; - _cleanup_error_free_ GError *error_local = NULL; + g_autofree gchar *filename = NULL; + g_autoptr(GError) error_local = NULL; _cleanup_node_unref_ GNode *root = NULL; g_return_val_if_fail (AS_IS_STORE (store), FALSE); @@ -1212,7 +1212,7 @@ as_store_from_xml (AsStore *store, const gchar *icon_root, GError **error) { - _cleanup_error_free_ GError *error_local = NULL; + g_autoptr(GError) error_local = NULL; _cleanup_node_unref_ GNode *root = NULL; g_return_val_if_fail (AS_IS_STORE (store), FALSE); @@ -1267,7 +1267,7 @@ as_store_to_xml (AsStore *store, AsNodeToXmlFlags flags) GString *xml; guint i; gchar version[6]; - _cleanup_free_ AsNodeContext *ctx = NULL; + g_autofree AsNodeContext *ctx = NULL; /* get XML text */ node_root = as_node_new (); @@ -1353,12 +1353,12 @@ as_store_to_file (AsStore *store, GCancellable *cancellable, GError **error) { - _cleanup_error_free_ GError *error_local = NULL; - _cleanup_object_unref_ GOutputStream *out2 = NULL; - _cleanup_object_unref_ GOutputStream *out = NULL; - _cleanup_object_unref_ GZlibCompressor *compressor = NULL; + g_autoptr(GError) error_local = NULL; + g_autoptr(GOutputStream) out2 = NULL; + g_autoptr(GOutputStream) out = NULL; + g_autoptr(GZlibCompressor) compressor = NULL; _cleanup_string_free_ GString *xml = NULL; - _cleanup_free_ gchar *basename = NULL; + g_autofree gchar *basename = NULL; /* check if compressed */ basename = g_file_get_basename (file); @@ -1639,7 +1639,7 @@ as_store_guess_origin_fallback (AsStore *store, GError **error) { gchar *tmp; - _cleanup_free_ gchar *origin_fallback = NULL; + g_autofree gchar *origin_fallback = NULL; /* the first component of the file (e.g. "fedora-20.xml.gz) * is used for the icon directory as we might want to clean up @@ -1674,7 +1674,7 @@ as_store_load_app_info_file (AsStore *store, GCancellable *cancellable, GError **error) { - _cleanup_object_unref_ GFile *file = NULL; + g_autoptr(GFile) file = NULL; /* guess this based on the name */ if (!as_store_guess_origin_fallback (store, path_xml, error)) @@ -1703,10 +1703,10 @@ as_store_load_app_info (AsStore *store, { AsStorePrivate *priv = GET_PRIVATE (store); const gchar *tmp; - _cleanup_dir_close_ GDir *dir = NULL; - _cleanup_error_free_ GError *error_local = NULL; - _cleanup_free_ gchar *icon_root = NULL; - _cleanup_free_ gchar *path_md = NULL; + g_autoptr(GDir) dir = NULL; + g_autoptr(GError) error_local = NULL; + g_autofree gchar *icon_root = NULL; + g_autofree gchar *path_md = NULL; _cleanup_uninhibit_ guint32 *tok = NULL; /* emit once when finished */ @@ -1727,7 +1727,7 @@ as_store_load_app_info (AsStore *store, } icon_root = g_build_filename (path, "icons", NULL); while ((tmp = g_dir_read_name (dir)) != NULL) { - _cleanup_free_ gchar *filename_md = NULL; + g_autofree gchar *filename_md = NULL; filename_md = g_build_filename (path_md, tmp, NULL); if (!as_store_load_app_info_file (store, filename_md, @@ -1759,9 +1759,9 @@ as_store_add_app_install_screenshot (AsApp *app) { GPtrArray *pkgnames; const gchar *pkgname; - _cleanup_free_ gchar *url = NULL; - _cleanup_object_unref_ AsImage *im = NULL; - _cleanup_object_unref_ AsScreenshot *ss = NULL; + g_autofree gchar *url = NULL; + g_autoptr(AsImage) im = NULL; + g_autoptr(AsScreenshot) ss = NULL; /* get the default package name */ pkgnames = as_app_get_pkgnames (app); @@ -1795,8 +1795,8 @@ as_store_load_app_install_file (AsStore *store, AsIcon *icon; GPtrArray *icons; guint i; - _cleanup_error_free_ GError *error_local = NULL; - _cleanup_object_unref_ AsApp *app = NULL; + g_autoptr(GError) error_local = NULL; + g_autoptr(AsApp) app = NULL; app = as_app_new (); as_app_set_icon_path (app, path_icons); @@ -1846,10 +1846,10 @@ as_store_load_app_install (AsStore *store, GError **error) { const gchar *tmp; - _cleanup_dir_close_ GDir *dir = NULL; - _cleanup_error_free_ GError *error_local = NULL; - _cleanup_free_ gchar *path_desktop = NULL; - _cleanup_free_ gchar *path_icons = NULL; + g_autoptr(GDir) dir = NULL; + g_autoptr(GError) error_local = NULL; + g_autofree gchar *path_desktop = NULL; + g_autofree gchar *path_icons = NULL; path_desktop = g_build_filename (path, "desktop", NULL); if (!g_file_test (path_desktop, G_FILE_TEST_EXISTS)) @@ -1867,7 +1867,7 @@ as_store_load_app_install (AsStore *store, path_icons = g_build_filename (path, "icons", NULL); while ((tmp = g_dir_read_name (dir)) != NULL) { - _cleanup_free_ gchar *filename = NULL; + g_autofree gchar *filename = NULL; if (!g_str_has_suffix (tmp, ".desktop")) continue; filename = g_build_filename (path_desktop, tmp, NULL); @@ -1894,7 +1894,7 @@ as_store_load_installed (AsStore *store, AsStorePrivate *priv = GET_PRIVATE (store); GError *error_local = NULL; const gchar *tmp; - _cleanup_dir_close_ GDir *dir = NULL; + g_autoptr(GDir) dir = NULL; _cleanup_uninhibit_ guint32 *tok = NULL; dir = g_dir_open (path, 0, error); @@ -1910,8 +1910,8 @@ as_store_load_installed (AsStore *store, while ((tmp = g_dir_read_name (dir)) != NULL) { AsApp *app_tmp; - _cleanup_free_ gchar *filename = NULL; - _cleanup_object_unref_ AsApp *app = NULL; + g_autofree gchar *filename = NULL; + g_autoptr(AsApp) app = NULL; filename = g_build_filename (path, tmp, NULL); if (!g_file_test (filename, G_FILE_TEST_IS_REGULAR)) continue; @@ -2003,8 +2003,8 @@ as_store_load (AsStore *store, const gchar *tmp; gchar *path; guint i; - _cleanup_ptrarray_unref_ GPtrArray *app_info = NULL; - _cleanup_ptrarray_unref_ GPtrArray *installed = NULL; + g_autoptr(GPtrArray) app_info = NULL; + g_autoptr(GPtrArray) installed = NULL; _cleanup_uninhibit_ guint32 *tok = NULL; /* system locations */ @@ -2057,7 +2057,7 @@ as_store_load (AsStore *store, /* load each app-info path if it exists */ tok = as_store_changed_inhibit (store); for (i = 0; i < app_info->len; i++) { - _cleanup_free_ gchar *dest = NULL; + g_autofree gchar *dest = NULL; tmp = g_ptr_array_index (app_info, i); dest = g_build_filename (priv->destdir ? priv->destdir : "/", tmp, NULL); if (!g_file_test (dest, G_FILE_TEST_EXISTS)) @@ -2070,7 +2070,7 @@ as_store_load (AsStore *store, /* load each appdata and desktop path if it exists */ for (i = 0; i < installed->len; i++) { - _cleanup_free_ gchar *dest = NULL; + g_autofree gchar *dest = NULL; tmp = g_ptr_array_index (installed, i); dest = g_build_filename (priv->destdir ? priv->destdir : "/", tmp, NULL); if (!g_file_test (dest, G_FILE_TEST_EXISTS)) @@ -2081,7 +2081,7 @@ as_store_load (AsStore *store, /* ubuntu specific */ if ((flags & AS_STORE_LOAD_FLAG_APP_INSTALL) > 0) { - _cleanup_free_ gchar *dest = NULL; + g_autofree gchar *dest = NULL; dest = g_build_filename (priv->destdir ? priv->destdir : "/", "/usr/share/app-install", NULL); if (!as_store_load_app_install (store, dest, cancellable, error)) @@ -2106,7 +2106,7 @@ as_store_validate_add (GPtrArray *problems, AsProblemKind kind, const gchar *fmt AsProblem *problem; guint i; va_list args; - _cleanup_free_ gchar *str = NULL; + g_autofree gchar *str = NULL; va_start (args, fmt); str = g_strdup_vprintf (fmt, args); @@ -2181,7 +2181,7 @@ as_store_validate (AsStore *store, AsAppValidateFlags flags, GError **error) for (i = 0; i < priv->array->len; i++) { AsProblem *prob; guint j; - _cleanup_ptrarray_unref_ GPtrArray *probs_app = NULL; + g_autoptr(GPtrArray) probs_app = NULL; app = g_ptr_array_index (priv->array, i); if (priv->api_version < 0.3) { diff --git a/libappstream-glib/as-utils.c b/libappstream-glib/as-utils.c index 6261722..aa34274 100644 --- a/libappstream-glib/as-utils.c +++ b/libappstream-glib/as-utils.c @@ -81,7 +81,7 @@ as_markup_strsplit_words (const gchar *text, guint line_len) GPtrArray *lines; guint i; _cleanup_string_free_ GString *curline = NULL; - _cleanup_strv_free_ gchar **tokens = NULL; + g_auto(GStrv) tokens = NULL; /* sanity check */ if (text == NULL || text[0] == '\0') @@ -130,7 +130,7 @@ static void as_markup_render_para (GString *str, AsMarkupConvertFormat format, const gchar *data) { guint i; - _cleanup_strv_free_ gchar **spl = NULL; + g_auto(GStrv) spl = NULL; if (str->len > 0) g_string_append (str, "\n"); @@ -156,7 +156,7 @@ static void as_markup_render_li (GString *str, AsMarkupConvertFormat format, const gchar *data) { guint i; - _cleanup_strv_free_ gchar **spl = NULL; + g_auto(GStrv) spl = NULL; switch (format) { case AS_MARKUP_CONVERT_FORMAT_SIMPLE: @@ -319,8 +319,8 @@ as_hash_lookup_by_locale (GHashTable *hash, const gchar *locale) gboolean as_utils_is_stock_icon_name (const gchar *name) { - _cleanup_bytes_unref_ GBytes *data = NULL; - _cleanup_free_ gchar *key = NULL; + g_autoptr(GBytes) data = NULL; + g_autofree gchar *key = NULL; /* load the readonly data section and look for the icon name */ data = g_resource_lookup_data (as_get_resource (), @@ -346,8 +346,8 @@ as_utils_is_stock_icon_name (const gchar *name) gboolean as_utils_is_spdx_license_id (const gchar *license_id) { - _cleanup_bytes_unref_ GBytes *data = NULL; - _cleanup_free_ gchar *key = NULL; + g_autoptr(GBytes) data = NULL; + g_autofree gchar *key = NULL; /* this is used to map non-SPDX licence-ids to legitimate values */ if (g_str_has_prefix (license_id, "LicenseRef-")) @@ -378,9 +378,9 @@ gboolean as_utils_is_blacklisted_id (const gchar *desktop_id) { guint i; - _cleanup_bytes_unref_ GBytes *data = NULL; - _cleanup_free_ gchar *key = NULL; - _cleanup_strv_free_ gchar **split = NULL; + g_autoptr(GBytes) data = NULL; + g_autofree gchar *key = NULL; + g_auto(GStrv) split = NULL; /* load the readonly data section and look for the icon name */ data = g_resource_lookup_data (as_get_resource (), @@ -410,8 +410,8 @@ as_utils_is_blacklisted_id (const gchar *desktop_id) gboolean as_utils_is_environment_id (const gchar *environment_id) { - _cleanup_bytes_unref_ GBytes *data = NULL; - _cleanup_free_ gchar *key = NULL; + g_autoptr(GBytes) data = NULL; + g_autofree gchar *key = NULL; /* load the readonly data section and look for the icon name */ data = g_resource_lookup_data (as_get_resource (), @@ -437,8 +437,8 @@ as_utils_is_environment_id (const gchar *environment_id) gboolean as_utils_is_category_id (const gchar *category_id) { - _cleanup_bytes_unref_ GBytes *data = NULL; - _cleanup_free_ gchar *key = NULL; + g_autoptr(GBytes) data = NULL; + g_autofree gchar *key = NULL; /* load the readonly data section and look for the icon name */ data = g_resource_lookup_data (as_get_resource (), @@ -468,7 +468,7 @@ as_utils_spdx_license_tokenize_drop (AsUtilsSpdxHelper *helper) { const gchar *tmp = helper->collect->str; guint i; - _cleanup_free_ gchar *last_literal = NULL; + g_autofree gchar *last_literal = NULL; struct { const gchar *old; const gchar *new; @@ -634,7 +634,7 @@ gboolean as_utils_is_spdx_license (const gchar *license) { guint i; - _cleanup_strv_free_ gchar **tokens = NULL; + g_auto(GStrv) tokens = NULL; /* no license information whatsoever */ if (g_strcmp0 (license, "NONE") == 0) @@ -789,8 +789,8 @@ as_pixbuf_blur (GdkPixbuf *src, gint radius, gint iterations) { gint kernel_size; gint i; - _cleanup_free_ guchar *div_kernel_size = NULL; - _cleanup_object_unref_ GdkPixbuf *tmp = NULL; + g_autofree guchar *div_kernel_size = NULL; + g_autoptr(GdkPixbuf) tmp = NULL; tmp = gdk_pixbuf_new (gdk_pixbuf_get_colorspace (src), gdk_pixbuf_get_has_alpha (src), @@ -829,7 +829,7 @@ as_pixbuf_sharpen (GdkPixbuf *src, gint radius, gdouble amount) guchar *p_blurred_row; guchar *p_src; guchar *p_src_row; - _cleanup_object_unref_ GdkPixbuf *blurred = NULL; + g_autoptr(GdkPixbuf) blurred = NULL; blurred = gdk_pixbuf_copy (src); as_pixbuf_blur (blurred, radius, 3); @@ -923,7 +923,7 @@ as_utils_find_icon_filename_full (const gchar *destdir, "status", "stock", NULL }; - _cleanup_free_ gchar *prefix = NULL; + g_autofree gchar *prefix = NULL; /* fallback */ if (destdir == NULL) @@ -931,7 +931,7 @@ as_utils_find_icon_filename_full (const gchar *destdir, /* is this an absolute path */ if (search[0] == '/') { - _cleanup_free_ gchar *tmp = NULL; + g_autofree gchar *tmp = NULL; tmp = g_build_filename (destdir, search, NULL); if (!g_file_test (tmp, G_FILE_TEST_EXISTS)) { g_set_error (error, @@ -964,7 +964,7 @@ as_utils_find_icon_filename_full (const gchar *destdir, for (i = 0; sizes[i] != NULL; i++) { for (m = 0; types[m] != NULL; m++) { for (j = 0; supported_ext[j] != NULL; j++) { - _cleanup_free_ gchar *tmp = NULL; + g_autofree gchar *tmp = NULL; tmp = g_strdup_printf ("%s/share/icons/" "%s/%s/%s/%s%s", prefix, @@ -983,7 +983,7 @@ as_utils_find_icon_filename_full (const gchar *destdir, /* pixmap */ for (i = 0; pixmap_dirs[i] != NULL; i++) { for (j = 0; supported_ext[j] != NULL; j++) { - _cleanup_free_ gchar *tmp = NULL; + g_autofree gchar *tmp = NULL; tmp = g_strdup_printf ("%s/share/%s/%s%s", prefix, pixmap_dirs[i], @@ -1056,8 +1056,8 @@ as_utils_install_icon (AsUtilsLocation location, int r; struct archive *arch = NULL; struct archive_entry *entry; - _cleanup_free_ gchar *data = NULL; - _cleanup_free_ gchar *dir = NULL; + g_autofree gchar *data = NULL; + g_autofree gchar *dir = NULL; dir = g_strdup_printf ("%s%s/app-info/icons/%s", destdir, @@ -1086,7 +1086,7 @@ as_utils_install_icon (AsUtilsLocation location, /* decompress each file */ for (;;) { - _cleanup_free_ gchar *buf = NULL; + g_autofree gchar *buf = NULL; r = archive_read_next_header (arch, &entry); if (r == ARCHIVE_EOF) @@ -1113,7 +1113,7 @@ as_utils_install_icon (AsUtilsLocation location, /* update hardlinks */ tmp = archive_entry_hardlink (entry); if (tmp != NULL) { - _cleanup_free_ gchar *buf_link = NULL; + g_autofree gchar *buf_link = NULL; buf_link = g_build_filename (dir, tmp, NULL); archive_entry_update_hardlink_utf8 (entry, buf_link); } @@ -1121,7 +1121,7 @@ as_utils_install_icon (AsUtilsLocation location, /* update symlinks */ tmp = archive_entry_symlink (entry); if (tmp != NULL) { - _cleanup_free_ gchar *buf_link = NULL; + g_autofree gchar *buf_link = NULL; buf_link = g_build_filename (dir, tmp, NULL); archive_entry_update_symlink_utf8 (entry, buf_link); } @@ -1156,11 +1156,11 @@ as_utils_install_xml (const gchar *filename, GError **error) { gchar *tmp; - _cleanup_free_ gchar *basename = NULL; - _cleanup_free_ gchar *path_dest = NULL; - _cleanup_free_ gchar *path_parent = NULL; - _cleanup_object_unref_ GFile *file_dest = NULL; - _cleanup_object_unref_ GFile *file_src = NULL; + g_autofree gchar *basename = NULL; + g_autofree gchar *path_dest = NULL; + g_autofree gchar *path_parent = NULL; + g_autoptr(GFile) file_dest = NULL; + g_autoptr(GFile) file_src = NULL; /* create directory structure */ path_parent = g_strdup_printf ("%s%s", destdir, dir); @@ -1176,7 +1176,7 @@ as_utils_install_xml (const gchar *filename, file_src = g_file_new_for_path (filename); basename = g_path_get_basename (filename); if (origin != NULL) { - _cleanup_free_ gchar *basename_new = NULL; + g_autofree gchar *basename_new = NULL; tmp = g_strstr_len (basename, -1, "."); if (tmp == NULL) { g_set_error (error, @@ -1203,7 +1203,7 @@ as_utils_install_xml (const gchar *filename, /* fix the origin */ if (origin != NULL) { - _cleanup_object_unref_ AsStore *store = NULL; + g_autoptr(AsStore) store = NULL; store = as_store_new (); if (!as_store_from_file (store, file_dest, NULL, NULL, error)) return FALSE; @@ -1240,8 +1240,8 @@ as_utils_install_filename (AsUtilsLocation location, { gboolean ret = FALSE; gchar *tmp; - _cleanup_free_ gchar *basename = NULL; - _cleanup_free_ gchar *path = NULL; + g_autofree gchar *basename = NULL; + g_autofree gchar *path = NULL; /* default value */ if (destdir == NULL) @@ -1354,7 +1354,7 @@ as_utils_search_tokenize (const gchar *search) gchar **values = NULL; guint i; guint idx = 0; - _cleanup_strv_free_ gchar **tmp = NULL; + g_auto(GStrv) tmp = NULL; /* only add keywords that are long enough */ tmp = g_strsplit (search, " ", -1); @@ -1391,8 +1391,8 @@ as_utils_vercmp (const gchar *version_a, const gchar *version_b) gint64 ver_b; guint i; guint longest_split; - _cleanup_strv_free_ gchar **split_a = NULL; - _cleanup_strv_free_ gchar **split_b = NULL; + g_auto(GStrv) split_a = NULL; + g_auto(GStrv) split_b = NULL; /* sanity check */ if (version_a == NULL || version_b == NULL) @@ -1484,7 +1484,7 @@ as_utils_guid_is_xdigit (const gchar *str) gboolean as_utils_guid_is_valid (const gchar *guid) { - _cleanup_strv_free_ gchar **split = NULL; + g_auto(GStrv) split = NULL; if (guid == NULL) return FALSE; split = g_strsplit (guid, "-", -1); diff --git a/libappstream-glib/as-yaml.c b/libappstream-glib/as-yaml.c index f226c52..74fdd41 100644 --- a/libappstream-glib/as-yaml.c +++ b/libappstream-glib/as-yaml.c @@ -330,11 +330,11 @@ as_yaml_from_file (GFile *file, GCancellable *cancellable, GError **error) #if AS_BUILD_DEP11 const gchar *content_type = NULL; yaml_parser_t parser; - _cleanup_free_ gchar *data = NULL; - _cleanup_object_unref_ GConverter *conv = NULL; - _cleanup_object_unref_ GFileInfo *info = NULL; - _cleanup_object_unref_ GInputStream *file_stream = NULL; - _cleanup_object_unref_ GInputStream *stream_data = NULL; + g_autofree gchar *data = NULL; + g_autoptr(GConverter) conv = NULL; + g_autoptr(GFileInfo) info = NULL; + g_autoptr(GInputStream) file_stream = NULL; + g_autoptr(GInputStream) stream_data = NULL; /* what kind of file is this */ info = g_file_query_info (file, |