summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2013-08-02 18:33:15 -0400
committerColin Walters <walters@verbum.org>2013-08-02 18:34:16 -0400
commita53219add5cbf9a9026422ea72b2e37dc3febe52 (patch)
treede1f827ce7f1b70f4a9d31eeb3435edaf3b57733
parentc541759c92667fdf50975e4919b590b9091d2c65 (diff)
downloadlibgsystem-a53219add5cbf9a9026422ea72b2e37dc3febe52.tar.gz
localalloc: Add gs_unref_array()
Requested by NetworkManager team.
-rw-r--r--gsystem-local-alloc.c6
-rw-r--r--gsystem-local-alloc.h11
2 files changed, 17 insertions, 0 deletions
diff --git a/gsystem-local-alloc.c b/gsystem-local-alloc.c
index 243f7ac..fbf1997 100644
--- a/gsystem-local-alloc.c
+++ b/gsystem-local-alloc.c
@@ -114,6 +114,12 @@ gs_local_ptrarray_unref (void *loc)
}
void
+gs_local_array_unref (void *loc)
+{
+ _gs_local_free(GArray, g_array_unref);
+}
+
+void
gs_local_hashtable_unref (void *loc)
{
_gs_local_free(GHashTable, g_hash_table_unref);
diff --git a/gsystem-local-alloc.h b/gsystem-local-alloc.h
index a44c4d4..8797cac 100644
--- a/gsystem-local-alloc.h
+++ b/gsystem-local-alloc.h
@@ -34,6 +34,7 @@ void gs_local_free (void *loc);
void gs_local_obj_unref (void *loc);
void gs_local_variant_unref (void *loc);
void gs_local_variant_iter_free (void *loc);
+void gs_local_array_unref (void *loc);
void gs_local_ptrarray_unref (void *loc);
void gs_local_hashtable_unref (void *loc);
@@ -71,6 +72,16 @@ void gs_local_hashtable_unref (void *loc);
#define gs_free_variant_iter __attribute__ ((cleanup(gs_local_variant_iter_free)))
/**
+ * gs_unref_array:
+ *
+ * Call g_array_unref() on a variable location when it goes out of
+ * scope. Note that unlike g_array_unref(), the variable may be
+ * %NULL.
+
+ */
+#define gs_unref_array __attribute__ ((cleanup(gs_local_array_unref)))
+
+/**
* gs_unref_ptrarray:
*
* Call g_ptr_array_unref() on a variable location when it goes out of