[libvirt] [PATCH 1/5] virsh: Allow using VIR_AUTOPTR for releasing virDomainPtr in virsh

Peter Krempa posted 5 patches 6 years, 4 months ago
[libvirt] [PATCH 1/5] virsh: Allow using VIR_AUTOPTR for releasing virDomainPtr in virsh
Posted by Peter Krempa 6 years, 4 months ago
I opted to alias the 'virDomainType' to 'virshDomain' so that it's
obvious in all cases that this is a virsh-only construct. This is also
somewhat consistent with virsh's use of 'virshDomainFree' wrapper for
the freeing function which actually accepts NULL.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 tools/virsh-util.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/virsh-util.h b/tools/virsh-util.h
index 9005aa9d36..7fdd39dd12 100644
--- a/tools/virsh-util.h
+++ b/tools/virsh-util.h
@@ -39,8 +39,11 @@ virshCommandOptDomain(vshControl *ctl,
                       const vshCmd *cmd,
                       const char **name);

+typedef virDomain virshDomain;
+
 void
 virshDomainFree(virDomainPtr dom);
+VIR_DEFINE_AUTOPTR_FUNC(virshDomain, virshDomainFree);

 void
 virshDomainCheckpointFree(virDomainCheckpointPtr chk);
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/5] virsh: Allow using VIR_AUTOPTR for releasing virDomainPtr in virsh
Posted by Daniel Henrique Barboza 6 years, 4 months ago

On 9/16/19 9:45 AM, Peter Krempa wrote:
> I opted to alias the 'virDomainType' to 'virshDomain' so that it's
> obvious in all cases that this is a virsh-only construct. This is also
> somewhat consistent with virsh's use of 'virshDomainFree' wrapper for
> the freeing function which actually accepts NULL.
>
> Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> ---

Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>

>   tools/virsh-util.h | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/tools/virsh-util.h b/tools/virsh-util.h
> index 9005aa9d36..7fdd39dd12 100644
> --- a/tools/virsh-util.h
> +++ b/tools/virsh-util.h
> @@ -39,8 +39,11 @@ virshCommandOptDomain(vshControl *ctl,
>                         const vshCmd *cmd,
>                         const char **name);
>
> +typedef virDomain virshDomain;
> +
>   void
>   virshDomainFree(virDomainPtr dom);
> +VIR_DEFINE_AUTOPTR_FUNC(virshDomain, virshDomainFree);
>
>   void
>   virshDomainCheckpointFree(virDomainCheckpointPtr chk);

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list