[libgsystem] localalloc: Add gs_unref_bytes()
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgsystem] localalloc: Add gs_unref_bytes()
- Date: Wed, 14 Aug 2013 14:52:43 +0000 (UTC)
commit 4150e6336881faec1a31f557567ca89c283b38c9
Author: Colin Walters <walters verbum org>
Date: Wed Aug 14 14:34:38 2013 +0200
localalloc: Add gs_unref_bytes()
Since I'm using these more now in ostree, and let's be comprehensive.
gsystem-local-alloc.c | 6 ++++++
gsystem-local-alloc.h | 10 ++++++++++
2 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/gsystem-local-alloc.c b/gsystem-local-alloc.c
index fa90654..3c3d50a 100644
--- a/gsystem-local-alloc.c
+++ b/gsystem-local-alloc.c
@@ -136,3 +136,9 @@ gs_local_checksum_free (void *loc)
{
_gs_local_free(GChecksum, g_checksum_free);
}
+
+void
+gs_local_bytes_unref (void *loc)
+{
+ _gs_local_free(GBytes, g_bytes_unref);
+}
diff --git a/gsystem-local-alloc.h b/gsystem-local-alloc.h
index 9f855d2..71ff07d 100644
--- a/gsystem-local-alloc.h
+++ b/gsystem-local-alloc.h
@@ -39,6 +39,7 @@ 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);
+void gs_local_bytes_unref (void *loc);
/**
* gs_free:
@@ -119,6 +120,15 @@ void gs_local_checksum_free (void *loc);
*/
#define gs_free_checksum __attribute__ ((cleanup(gs_local_checksum_free)))
+/**
+ * gs_unref_bytes:
+ *
+ * Call g_bytes_unref() on a variable location when it goes out
+ * of scope. Note that unlike g_bytes_unref(), the variable may
+ * be %NULL.
+ */
+#define gs_unref_bytes __attribute__ ((cleanup(gs_local_bytes_unref)))
+
G_END_DECLS
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]