summaryrefslogtreecommitdiff
path: root/libappstream-glib
diff options
context:
space:
mode:
authorKalev Lember <klember@redhat.com>2015-09-10 15:12:05 +0200
committerKalev Lember <klember@redhat.com>2015-09-10 15:21:38 +0200
commitb1bc5776bb3bbac508b793d00c80cd78d82cc8b3 (patch)
tree3347a2d9d87dd70d4903a1ff62d49e370305cfc1 /libappstream-glib
parent752e45e990a00331290067bdcb07a2f4ab2001ad (diff)
downloadappstream-glib-b1bc5776bb3bbac508b793d00c80cd78d82cc8b3.tar.gz
Use glib's cleanup functions for GString
... and bump glib dep to 2.45.8 for g_autoptr(GString) support.
Diffstat (limited to 'libappstream-glib')
-rw-r--r--libappstream-glib/as-app.c6
-rw-r--r--libappstream-glib/as-cleanup.h10
-rw-r--r--libappstream-glib/as-inf.c4
-rw-r--r--libappstream-glib/as-node.c3
-rw-r--r--libappstream-glib/as-release.c3
-rw-r--r--libappstream-glib/as-self-test.c14
-rw-r--r--libappstream-glib/as-store.c2
-rw-r--r--libappstream-glib/as-utils.c4
8 files changed, 17 insertions, 29 deletions
diff --git a/libappstream-glib/as-app.c b/libappstream-glib/as-app.c
index e34f8b5..ac4c3ff 100644
--- a/libappstream-glib/as-app.c
+++ b/libappstream-glib/as-app.c
@@ -3331,7 +3331,7 @@ as_app_node_parse_child (AsApp *app, GNode *n, AsAppParseFlags flags,
if (g_error_matches (error_local,
AS_NODE_ERROR,
AS_NODE_ERROR_INVALID_MARKUP)) {
- _cleanup_string_free_ GString *debug = NULL;
+ g_autoptr(GString) debug = NULL;
debug = as_node_to_xml (n, AS_NODE_TO_XML_FLAG_NONE);
g_warning ("ignoring description '%s' from %s: %s",
debug->str,
@@ -3354,7 +3354,7 @@ as_app_node_parse_child (AsApp *app, GNode *n, AsAppParseFlags flags,
as_node_get_attribute (n, "xml:lang"),
as_node_get_data (n));
} else {
- _cleanup_string_free_ GString *xml = NULL;
+ g_autoptr(GString) xml = NULL;
xml = as_node_to_xml (n->children,
AS_NODE_TO_XML_FLAG_INCLUDE_SIBLINGS);
as_app_set_description (app,
@@ -4422,7 +4422,7 @@ as_app_to_file (AsApp *app,
{
g_autofree AsNodeContext *ctx = NULL;
_cleanup_node_unref_ GNode *root = NULL;
- _cleanup_string_free_ GString *xml = NULL;
+ g_autoptr(GString) xml = NULL;
root = as_node_new ();
ctx = as_node_context_new ();
diff --git a/libappstream-glib/as-cleanup.h b/libappstream-glib/as-cleanup.h
index b8dc422..9196654 100644
--- a/libappstream-glib/as-cleanup.h
+++ b/libappstream-glib/as-cleanup.h
@@ -45,22 +45,12 @@ G_BEGIN_DECLS
func (*(Type*)v); \
}
-#define GS_DEFINE_CLEANUP_FUNCTIONt(Type, name, func) \
- static inline void name (void *v) \
- { \
- if (*(Type*)v) \
- func (*(Type*)v, TRUE); \
- }
-
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_FUNCTIONt(GString*, gs_local_free_string, g_string_free)
-
GS_DEFINE_CLEANUP_FUNCTION(void*, gs_local_free_libc, free)
#define _cleanup_free_libc_ __attribute__ ((cleanup(gs_local_free_libc)))
-#define _cleanup_string_free_ __attribute__ ((cleanup(gs_local_free_string)))
#define _cleanup_node_unref_ __attribute__ ((cleanup(gs_local_node_unref)))
#define _cleanup_yaml_unref_ __attribute__ ((cleanup(gs_local_yaml_unref)))
diff --git a/libappstream-glib/as-inf.c b/libappstream-glib/as-inf.c
index e90a953..d4bebea 100644
--- a/libappstream-glib/as-inf.c
+++ b/libappstream-glib/as-inf.c
@@ -31,10 +31,10 @@
#include "config.h"
+#include <gio/gio.h>
#include <string.h>
#include <stdlib.h>
-#include "as-cleanup.h"
#include "as-inf.h"
/**
@@ -696,7 +696,7 @@ as_inf_parse_line (AsInfHelper *helper, gchar *line, GError **error)
g_str_has_prefix (line, "HK")) {
guint i;
g_auto(GStrv) reg_split = NULL;
- _cleanup_string_free_ GString *str = NULL;
+ g_autoptr(GString) str = NULL;
str = g_string_new ("");
reg_split = g_strsplit (line, ",", -1);
for (i = 0; reg_split[i+1] != NULL; i++) {
diff --git a/libappstream-glib/as-node.c b/libappstream-glib/as-node.c
index d6ea765..f929979 100644
--- a/libappstream-glib/as-node.c
+++ b/libappstream-glib/as-node.c
@@ -37,7 +37,6 @@
#include <glib.h>
#include <string.h>
-#include "as-cleanup.h"
#include "as-node-private.h"
#include "as-utils-private.h"
@@ -759,7 +758,7 @@ as_node_to_file (const GNode *root,
GCancellable *cancellable,
GError **error)
{
- _cleanup_string_free_ GString *xml = NULL;
+ g_autoptr(GString) xml = NULL;
xml = as_node_to_xml (root, flags);
return g_file_replace_contents (file,
xml->str,
diff --git a/libappstream-glib/as-release.c b/libappstream-glib/as-release.c
index c790651..d7c01e7 100644
--- a/libappstream-glib/as-release.c
+++ b/libappstream-glib/as-release.c
@@ -39,7 +39,6 @@
#include <stdlib.h>
-#include "as-cleanup.h"
#include "as-checksum-private.h"
#include "as-node-private.h"
#include "as-release-private.h"
@@ -491,7 +490,7 @@ as_release_node_parse (AsRelease *release, GNode *node,
/* AppStream: multiple <description> tags */
if (as_node_context_get_source_kind (ctx) == AS_APP_SOURCE_KIND_APPSTREAM) {
for (n = node->children; n != NULL; n = n->next) {
- _cleanup_string_free_ GString *xml = NULL;
+ g_autoptr(GString) xml = NULL;
if (as_node_get_tag (n) != AS_TAG_DESCRIPTION)
continue;
if (n->children == NULL)
diff --git a/libappstream-glib/as-self-test.c b/libappstream-glib/as-self-test.c
index 3a69ae6..c10bdea 100644
--- a/libappstream-glib/as-self-test.c
+++ b/libappstream-glib/as-self-test.c
@@ -719,7 +719,7 @@ as_test_image_resize_func (void)
for (i = 0; i < AS_TEST_RESIZE_LAST; i++) {
g_autofree gchar *new_path = NULL;
- _cleanup_string_free_ GString *basename = NULL;
+ g_autoptr(GString) basename = NULL;
basename = g_string_new (tmp);
g_string_truncate (basename, basename->len - 4);
@@ -1966,7 +1966,7 @@ as_test_node_sort_func (void)
{
g_autoptr(GError) error = NULL;
_cleanup_node_unref_ GNode *root = NULL;
- _cleanup_string_free_ GString *str = NULL;
+ g_autoptr(GString) str = NULL;
root = as_node_from_xml ("<d>ddd</d><c>ccc</c><b>bbb</b><a>aaa</a>", 0, &error);
g_assert_no_error (error);
@@ -2273,7 +2273,7 @@ as_test_node_intltool_func (void)
{
GNode *n;
_cleanup_node_unref_ GNode *root = NULL;
- _cleanup_string_free_ GString *str = NULL;
+ g_autoptr(GString) str = NULL;
root = as_node_new ();
n = as_node_insert (root, "description", NULL, AS_NODE_INSERT_FLAG_NONE, NULL);
@@ -2428,7 +2428,7 @@ as_test_store_embedded_func (void)
gboolean ret;
g_autoptr(GError) error = NULL;
g_autoptr(AsStore) store = NULL;
- _cleanup_string_free_ GString *xml = NULL;
+ g_autoptr(GString) xml = NULL;
const gchar *xml_src =
"<components version=\"0.6\" origin=\"origin\">"
"<component type=\"desktop\">"
@@ -2673,7 +2673,7 @@ as_test_store_demote_func (void)
g_autoptr(AsApp) app_appdata = NULL;
g_autoptr(AsApp) app_desktop = NULL;
g_autoptr(AsStore) store = NULL;
- _cleanup_string_free_ GString *xml = NULL;
+ g_autoptr(GString) xml = NULL;
/* load example desktop file */
app_desktop = as_app_new ();
@@ -3069,7 +3069,7 @@ as_test_store_addons_func (void)
"</component>"
"</components>";
g_autoptr(AsStore) store = NULL;
- _cleanup_string_free_ GString *str = NULL;
+ g_autoptr(GString) str = NULL;
/* load a file to the store */
store = as_store_new ();
@@ -3726,7 +3726,7 @@ as_test_store_yaml_func (void)
g_autofree gchar *icon_root = NULL;
g_autoptr(AsStore) store = NULL;
g_autoptr(GFile) file = NULL;
- _cleanup_string_free_ GString *str = NULL;
+ g_autoptr(GString) str = NULL;
const gchar *xml =
"<components version=\"0.6\" origin=\"aequorea\">\n"
"<component type=\"desktop\">\n"
diff --git a/libappstream-glib/as-store.c b/libappstream-glib/as-store.c
index 1ad5987..e84c851 100644
--- a/libappstream-glib/as-store.c
+++ b/libappstream-glib/as-store.c
@@ -1357,7 +1357,7 @@ as_store_to_file (AsStore *store,
g_autoptr(GOutputStream) out2 = NULL;
g_autoptr(GOutputStream) out = NULL;
g_autoptr(GZlibCompressor) compressor = NULL;
- _cleanup_string_free_ GString *xml = NULL;
+ g_autoptr(GString) xml = NULL;
g_autofree gchar *basename = NULL;
/* check if compressed */
diff --git a/libappstream-glib/as-utils.c b/libappstream-glib/as-utils.c
index 376e228..4d12aed 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;
+ g_autoptr(GString) curline = NULL;
g_auto(GStrv) tokens = NULL;
/* sanity check */
@@ -196,7 +196,7 @@ as_markup_convert (const gchar *markup,
const gchar *tag;
const gchar *tag_c;
_cleanup_node_unref_ GNode *root = NULL;
- _cleanup_string_free_ GString *str = NULL;
+ g_autoptr(GString) str = NULL;
/* is this actually markup */
if (g_strstr_len (markup, -1, "<") == NULL)