summaryrefslogtreecommitdiff
path: root/libappstream-glib
diff options
context:
space:
mode:
Diffstat (limited to 'libappstream-glib')
-rw-r--r--libappstream-glib/as-app-desktop.c26
-rw-r--r--libappstream-glib/as-app-inf.c42
-rw-r--r--libappstream-glib/as-app-validate.c14
-rw-r--r--libappstream-glib/as-app.c56
-rw-r--r--libappstream-glib/as-cleanup.h33
-rw-r--r--libappstream-glib/as-icon.c28
-rw-r--r--libappstream-glib/as-image.c10
-rw-r--r--libappstream-glib/as-inf.c46
-rw-r--r--libappstream-glib/as-monitor.c16
-rw-r--r--libappstream-glib/as-node.c44
-rw-r--r--libappstream-glib/as-release.c4
-rw-r--r--libappstream-glib/as-screenshot.c10
-rw-r--r--libappstream-glib/as-self-test.c318
-rw-r--r--libappstream-glib/as-store.c96
-rw-r--r--libappstream-glib/as-utils.c82
-rw-r--r--libappstream-glib/as-yaml.c10
16 files changed, 401 insertions, 434 deletions
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,