From 3f54cb1ee4adb44f67869a098eb62ca8e9568fd9 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Wed, 14 Aug 2013 01:06:46 +0200 Subject: localalloc: Add cleanup functions for checksum and variant builders Used in ostree. --- gsystem-local-alloc.c | 12 ++++++++++++ gsystem-local-alloc.h | 19 +++++++++++++++++++ 2 files changed, 31 insertions(+) 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 @@ -107,6 +107,12 @@ gs_local_variant_iter_free (void *loc) _gs_local_free(GVariantIter, g_variant_iter_free); } +void +gs_local_variant_builder_free (void *loc) +{ + _gs_local_free(GVariantBuilder, g_variant_builder_free); +} + void gs_local_ptrarray_unref (void *loc) { @@ -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: @@ -71,6 +73,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: * @@ -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 -- cgit v1.2.1