Re: [PATCH 02/10] internal: Introduce macro for stealing pointers

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

 




On 08/03/2016 04:10 AM, 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)
> +
> +/**
>   * virCheckFlags:
>   * @supported: an OR'ed set of supported flags
>   * @retval: return value in case unsupported flags were passed
> 

While one can look at the code and deduce what it does - the name is not
that descriptive.  VIR_ASSIGN_PTR or VIR_ASSIGN_POINTER?  Just a thought...

It's also not used until patch 9 - perhaps move it a bit closer to that.

John

--
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]