Re: [GSoC] Design ideas for implementing cleanup attribute

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

 



On Wed, May 23, 2018 at 06:23:01PM +0200, Peter Krempa wrote:
> On Wed, May 23, 2018 at 18:05:17 +0200, Pavel Hrdina wrote:
> 
> [...]
> 
> > I liked the way how GLib is solving the issue so we can simply use the
> > same approach since it looks reasonable.
> > 
> > There would be three different macros that would be used to annotate
> > variable with attribute cleanup:
> > 
> > VIR_AUTOFREE char *str = NULL;
> 
> For consistency I'd prefer if the argument is in parentheses similarly
> to the ones below.

Yes, for consistency it can take the type as an argument but it's not
necessary since the type is not used by that macro.

> >     - this would call virFree on that variable
> > 
> > VIR_AUTOPTR(virDomain) domain = NULL;
> > 
> >     - this would call registered free function on that variable
> >     - to register the free function you would use:
> > 
> >         VIR_DEFINE_AUTOPTR_FUNC(virDomain, virDomainFree);
> 
> Did you mean virDomainPtr?

Right, it can be virDomainPtr since we already have these typedefs,
GLib implementation actually creates the same typedef inside the
G_DEFINE_AUTOPTR_CLEANUP_FUNC macro, we don't have to do it.

It also creates a wrapper function with a name based on the passed type
and that wrapper function is then used by g_autoptr() again based on the
passed type.

Pavel

Attachment: signature.asc
Description: PGP signature

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

  Powered by Linux