From 8ba987599ba6045dfe422e527d51aa3e090cd812 Mon Sep 17 00:00:00 2001 From: Christian Persch Date: Mon, 21 Oct 2013 14:44:49 +0200 Subject: localalloc: Add gs_free_error --- gsystem-local-alloc.c | 6 ++++++ gsystem-local-alloc.h | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/gsystem-local-alloc.c b/gsystem-local-alloc.c index fa4971d..3879b00 100644 --- a/gsystem-local-alloc.c +++ b/gsystem-local-alloc.c @@ -148,3 +148,9 @@ gs_local_strfreev (void *loc) { _gs_local_free(char **, g_strfreev); } + +void +gs_local_free_error (void *loc) +{ + _gs_local_free(GError*, g_error_free); +} diff --git a/gsystem-local-alloc.h b/gsystem-local-alloc.h index 4c63dcf..150748c 100644 --- a/gsystem-local-alloc.h +++ b/gsystem-local-alloc.h @@ -41,6 +41,7 @@ void gs_local_hashtable_unref (void *loc); void gs_local_checksum_free (void *loc); void gs_local_bytes_unref (void *loc); void gs_local_strfreev (void *loc); +void gs_local_free_error (void *loc); /** * gs_free: @@ -137,6 +138,13 @@ void gs_local_strfreev (void *loc); */ #define gs_strfreev __attribute__ ((cleanup(gs_local_strfreev))) +/** + * gs_free_error: + * + * Call g_error_free() on a variable location when it goes out of scope. + */ +#define gs_free_error __attribute__ ((cleanup(gs_local_free_error))) + G_END_DECLS #endif -- cgit v1.2.1