[libgsystem] localalloc: Add cleanup functions for checksum and variant builders
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgsystem] localalloc: Add cleanup functions for checksum and variant builders
- Date: Tue, 13 Aug 2013 23:07:23 +0000 (UTC)
commit 3f54cb1ee4adb44f67869a098eb62ca8e9568fd9
Author: Colin Walters <walters verbum org>
Date: Wed Aug 14 01:06:46 2013 +0200
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(+), 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]