qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/2] introduce QEMU_AUTO_VFREE


From: Vladimir Sementsov-Ogievskiy
Subject: [PATCH 1/2] introduce QEMU_AUTO_VFREE
Date: Sat, 19 Jun 2021 17:21:19 +0300

Introduce a convenient macro, that works for qemu_memalign() like
g_autofree works with g_malloc.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 include/qemu/osdep.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index 236a045671..844658a764 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -366,6 +366,8 @@ void *qemu_anon_ram_alloc(size_t size, uint64_t *align, 
bool shared);
 void qemu_vfree(void *ptr);
 void qemu_anon_ram_free(void *ptr, size_t size);
 
+#define QEMU_AUTO_VFREE __attribute__((cleanup(qemu_vfree)))
+
 #define QEMU_MADV_INVALID -1
 
 #if defined(CONFIG_MADVISE)
-- 
2.29.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]