summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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