summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2013-08-14 14:34:38 +0200
committerColin Walters <walters@verbum.org>2013-08-14 14:34:38 +0200
commit4150e6336881faec1a31f557567ca89c283b38c9 (patch)
treef62f7ff5d03196aa40a7cb629bc3f925c9c2e628
parente9cf24540e0d6cb7e5f52b3facdea0b24a69e350 (diff)
downloadlibgsystem-4150e6336881faec1a31f557567ca89c283b38c9.tar.gz
localalloc: Add gs_unref_bytes()
Since I'm using these more now in ostree, and let's be comprehensive.
-rw-r--r--gsystem-local-alloc.c6
-rw-r--r--gsystem-local-alloc.h10
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