summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2013-08-14 01:06:46 +0200
committerColin Walters <walters@verbum.org>2013-08-14 01:06:46 +0200
commit3f54cb1ee4adb44f67869a098eb62ca8e9568fd9 (patch)
tree93525e5fe3165ada3c300ea94bc224bfffde4aef
parentd2deea193d946cba7778a726e45ede0ac56db715 (diff)
downloadlibgsystem-3f54cb1ee4adb44f67869a098eb62ca8e9568fd9.tar.gz
localalloc: Add cleanup functions for checksum and variant builders
Used in ostree.
-rw-r--r--gsystem-local-alloc.c12
-rw-r--r--gsystem-local-alloc.h19
2 files changed, 31 insertions, 0 deletions
diff --git a/gsystem-local-alloc.c b/gsystem-local-alloc.c
index fbf1997..acac1a6 100644
--- a/gsystem-local-alloc.c
+++ b/gsystem-local-alloc.c
@@ -108,6 +108,12 @@ gs_local_variant_iter_free (void *loc)
}
void
+gs_local_variant_builder_free (void *loc)
+{
+ _gs_local_free(GVariantBuilder, g_variant_builder_free);
+}
+
+void
gs_local_ptrarray_unref (void *loc)
{
_gs_local_free(GPtrArray, g_ptr_array_unref);
@@ -124,3 +130,9 @@ gs_local_hashtable_unref (void *loc)
{
_gs_local_free(GHashTable, g_hash_table_unref);
}
+
+void
+gs_local_checksum_free (void *loc)
+{
+ _gs_local_free(GChecksum, g_checksum_free);
+}
diff --git a/gsystem-local-alloc.h b/gsystem-local-alloc.h
index 8797cac..abdd371 100644
--- a/gsystem-local-alloc.h
+++ b/gsystem-local-alloc.h
@@ -34,9 +34,11 @@ 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_variant_builder_free (void *loc);
void gs_local_array_unref (void *loc);
void gs_local_ptrarray_unref (void *loc);
void gs_local_hashtable_unref (void *loc);
+void gs_local_checksum_free (void *loc);
/**
* gs_free:
@@ -72,6 +74,14 @@ void gs_local_hashtable_unref (void *loc);
#define gs_free_variant_iter __attribute__ ((cleanup(gs_local_variant_iter_free)))
/**
+ * gs_free_variant_builder:
+ *
+ * Call g_variant_builder_free() on a variable location when it goes out of
+ * scope.
+ */
+#define gs_free_variant_builder __attribute__ ((cleanup(gs_local_variant_builder_free)))
+
+/**
* gs_unref_array:
*
* Call g_array_unref() on a variable location when it goes out of
@@ -100,6 +110,15 @@ void gs_local_hashtable_unref (void *loc);
*/
#define gs_unref_hashtable __attribute__ ((cleanup(gs_local_hashtable_unref)))
+/**
+ * gs_free_checksum:
+ *
+ * Call g_checksum_free() on a variable location when it goes out
+ * of scope. Note that unlike g_checksum_free(), the variable may
+ * be %NULL.
+ */
+#define gs_free_checksum __attribute__ ((cleanup(gs_local_free_checksum)))
+
G_END_DECLS
#endif