6ae9ed
From 42a6d5d30c4f9cca3913996f6cccf6dd383a3fd3 Mon Sep 17 00:00:00 2001
6ae9ed
Message-Id: <42a6d5d30c4f9cca3913996f6cccf6dd383a3fd3@dist-git>
6ae9ed
From: Peter Krempa <pkrempa@redhat.com>
6ae9ed
Date: Wed, 24 Aug 2016 16:11:10 -0400
6ae9ed
Subject: [PATCH] internal: Introduce macro for stealing pointers
6ae9ed
6ae9ed
https://bugzilla.redhat.com/show_bug.cgi?id=1097930
6ae9ed
https://bugzilla.redhat.com/show_bug.cgi?id=1224341
6ae9ed
6ae9ed
VIR_STEAL_PTR copies the pointer from the second argument into the
6ae9ed
first argument and then sets the second to NULL.
6ae9ed
6ae9ed
(cherry picked from commit 5b7dedc995a6b33a7be33a67290155627a133a7f)
6ae9ed
---
6ae9ed
 src/internal.h | 12 ++++++++++++
6ae9ed
 1 file changed, 12 insertions(+)
6ae9ed
6ae9ed
diff --git a/src/internal.h b/src/internal.h
6ae9ed
index 0dc34c7..d8cc5ad 100644
6ae9ed
--- a/src/internal.h
6ae9ed
+++ b/src/internal.h
6ae9ed
@@ -307,6 +307,18 @@
6ae9ed
     } while (0)
6ae9ed
 
6ae9ed
 /**
6ae9ed
+ * VIR_STEAL_PTR:
6ae9ed
+ *
6ae9ed
+ * Steals pointer passed as second argument into the first argument. Second
6ae9ed
+ * argument must not have side effects.
6ae9ed
+ */
6ae9ed
+# define VIR_STEAL_PTR(a, b)  \
6ae9ed
+    do {                      \
6ae9ed
+        (a) = (b);            \
6ae9ed
+        (b) = NULL;           \
6ae9ed
+    } while (0)
6ae9ed
+
6ae9ed
+/**
6ae9ed
  * virCheckFlags:
6ae9ed
  * @supported: an OR'ed set of supported flags
6ae9ed
  * @retval: return value in case unsupported flags were passed
6ae9ed
-- 
6ae9ed
2.10.0
6ae9ed