summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2015-09-13 12:28:27 +0100
committerRichard Hughes <richard@hughsie.com>2015-09-13 12:28:27 +0100
commitdc22accbc209994aca5a3b60d7d9f6b04e44c23a (patch)
treee92ecf6664a902800f725d3d87d5b0794e843f54
parentab8fb24ccb6a5b6a36b7f80fc3b9192cb58b52a6 (diff)
parenta7883b85922f34938a2ddf9d42e9333cf13806a8 (diff)
downloadappstream-glib-dc22accbc209994aca5a3b60d7d9f6b04e44c23a.tar.gz
Merge pull request #61 from kalev/malloc-vs-g_malloc
Don't reallocate malloc'd memory with g_malloc
-rw-r--r--libappstream-builder/asb-self-test.c9
-rw-r--r--libappstream-glib/as-cleanup.h9
-rw-r--r--libappstream-glib/as-self-test.c7
3 files changed, 2 insertions, 23 deletions
diff --git a/libappstream-builder/asb-self-test.c b/libappstream-builder/asb-self-test.c
index 048d524..883ed07 100644
--- a/libappstream-builder/asb-self-test.c
+++ b/libappstream-builder/asb-self-test.c
@@ -25,8 +25,6 @@
#include <stdlib.h>
#include <locale.h>
-#include "as-cleanup.h"
-
#include "asb-context-private.h"
#include "asb-plugin.h"
#include "asb-plugin-loader.h"
@@ -43,7 +41,6 @@
static gchar *
asb_test_get_filename (const gchar *filename)
{
- _cleanup_free_libc_ gchar *tmp = NULL;
g_autofree gchar *path = NULL;
/* try the source then the destdir */
@@ -52,11 +49,7 @@ asb_test_get_filename (const gchar *filename)
g_free (path);
path = g_build_filename (TESTDIRBUILD, filename, NULL);
}
- /* glibc allocates a buffer */
- tmp = realpath (path, NULL);
- if (tmp == NULL)
- return NULL;
- return g_strdup (tmp);
+ return realpath (path, NULL);
}
/**
diff --git a/libappstream-glib/as-cleanup.h b/libappstream-glib/as-cleanup.h
index 9196654..e369a56 100644
--- a/libappstream-glib/as-cleanup.h
+++ b/libappstream-glib/as-cleanup.h
@@ -32,12 +32,6 @@
G_BEGIN_DECLS
-#define GS_DEFINE_CLEANUP_FUNCTION(Type, name, func) \
- static inline void name (void *v) \
- { \
- func (*(Type*)v); \
- }
-
#define GS_DEFINE_CLEANUP_FUNCTION0(Type, name, func) \
static inline void name (void *v) \
{ \
@@ -48,9 +42,6 @@ G_BEGIN_DECLS
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_FUNCTION(void*, gs_local_free_libc, free)
-
-#define _cleanup_free_libc_ __attribute__ ((cleanup(gs_local_free_libc)))
#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-self-test.c b/libappstream-glib/as-self-test.c
index eef4776..22ad0e9 100644
--- a/libappstream-glib/as-self-test.c
+++ b/libappstream-glib/as-self-test.c
@@ -76,15 +76,10 @@ as_test_compare_lines (const gchar *txt1, const gchar *txt2, GError **error)
static gchar *
as_test_get_filename (const gchar *filename)
{
- _cleanup_free_libc_ gchar *tmp = NULL;
g_autofree gchar *path = NULL;
path = g_build_filename (TESTDATADIR, filename, NULL);
- /* glibc allocates a buffer */
- tmp = realpath (path, NULL);
- if (tmp == NULL)
- return NULL;
- return g_strdup (tmp);
+ return realpath (path, NULL);
}
static GMainLoop *_test_loop = NULL;