
On Wed, Aug 03, 2016 at 10:10:54AM +0200, Peter Krempa wrote:
VIR_STEAL copies the second argument into the first and then sets it to NULL. This is useful for stealing pointers. --- src/internal.h | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/src/internal.h b/src/internal.h index 0dc34c7..c633ee6 100644 --- a/src/internal.h +++ b/src/internal.h @@ -307,6 +307,18 @@ } while (0)
/** + * VIR_STEAL: + * + * Steals pointer passed as second argument into the first argument. Second + * argument must not have side effects. + */ +# define VIR_STEAL(a, b) \ + do { \ + (a) = (b); \ + (b) = NULL;\ + } while (0)
I guess that there is no harm having this macro even though it's only two lines of code. I would align the backslash to the same column as we tend to do in libvirt code. ACK