[libvirt] [PATCH 5/7] util: alloc: Introduce 'VIR_AUTOCLEAN' macros for clearing stack'd structs

Eric Blake eblake at redhat.com
Thu Feb 21 17:48:56 UTC 2019


On 2/21/19 9:50 AM, Peter Krempa wrote:
> The new utility macros are useful for variables we put on the stack but
> require some cleanup. The most prominent of those is virBuffer which is
> used almost exclusively in that way.
> 
> Signed-off-by: Peter Krempa <pkrempa at redhat.com>
> ---
>  src/util/viralloc.h | 32 +++++++++++++++++++++++++++++++-
>  1 file changed, 31 insertions(+), 1 deletion(-)
> 

> 
> +/**
> + * VIR_AUTOCLEAN:
> + * @type: type of the variable to be cleared

To match what VIR_AUTOUNREF does, should this state:
to be clean'd automatically

> + *
> + * Macro to automatically calls destructor of @type variable declared directly

s/calls/call/

Is it actually a destructor, or just a cleanup function?

> + * when the variable goes out of scope.
> + * The destructor is defined by VIR_DEFINE_AUTOCLEAN_FUNC macro for the given
> + * type.
> + */
> +# define VIR_AUTOCLEAN(type) \
> +    __attribute__((cleanup(VIR_AUTOCLEAN_FUNC_NAME(type)))) type
> +
> +
>  /**
>   * VIR_AUTOUNREF:
>   * @type: type of an virObject subclass to be unref'd automatically
> 


-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org




More information about the libvir-list mailing list