diff options
author | Kalev Lember <klember@redhat.com> | 2015-09-08 14:30:28 +0200 |
---|---|---|
committer | Kalev Lember <klember@redhat.com> | 2015-09-08 14:32:23 +0200 |
commit | 6ef00b04680e3bfb8923158f7ffef3de8d9b09ef (patch) | |
tree | 0b21f7b95bc27223621ae657c2b04f20b78df877 /libappstream-builder | |
parent | a3d06c5cb6f85e963be74e8866e1c3bc71ee4990 (diff) | |
download | appstream-glib-6ef00b04680e3bfb8923158f7ffef3de8d9b09ef.tar.gz |
Use GLib's cleanup functions instead of libgsystem's
We still have a few types that don't support g_autoptr(), but very very
close to having everything ported over.
This also bumps gdk-pixbuf dep to 2.31.5 for the cleanup macro support.
Diffstat (limited to 'libappstream-builder')
29 files changed, 234 insertions, 234 deletions
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); |