[libvirt-php][PATCH 4/7] util: Introduce VIR_FREE

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

 



Just like libvirt has it. After freeing pointer set it to NULL to
avoid double frees.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/util.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/util.h b/src/util.h
index fcd4075..3af77d4 100644
--- a/src/util.h
+++ b/src/util.h
@@ -36,6 +36,12 @@
 # define DPRINTF(fmt, ...)      \
     debugPrint(debugSource, fmt, __VA_ARGS__)
 
+# define VIR_FREE(ptr) \
+    do { \
+        free(ptr); \
+        ptr = NULL; \
+    } while (0)
+
 # define ARRAY_CARDINALITY(array) (sizeof(array) / sizeof(array[0]))
 
 # define IS_BIGENDIAN (*(uint16_t *)"\0\xff" < 0x100)
-- 
2.13.6

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux