From: Peter Krempa Date: Sun, 31 Jul 2016 12:02:08 +0000 (+0200) Subject: internal: Introduce macro for stealing pointers X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=5b7dedc995a6b33a7be33a67290155627a133a7f;p=libvirt.git internal: Introduce macro for stealing pointers VIR_STEAL_PTR copies the pointer from the second argument into the first argument and then sets the second to NULL. --- diff --git a/src/internal.h b/src/internal.h index 0dc34c755d..d8cc5adc38 100644 --- a/src/internal.h +++ b/src/internal.h @@ -306,6 +306,18 @@ (a) = (a) ^ (b); \ } while (0) +/** + * VIR_STEAL_PTR: + * + * Steals pointer passed as second argument into the first argument. Second + * argument must not have side effects. + */ +# define VIR_STEAL_PTR(a, b) \ + do { \ + (a) = (b); \ + (b) = NULL; \ + } while (0) + /** * virCheckFlags: * @supported: an OR'ed set of supported flags