Re: [PATCH 07/11] util: convert virIdentity class to use GObject

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

 



On Mon, Sep 30, 2019 at 03:04:38PM +0200, Ján Tomko wrote:
> On Fri, Sep 27, 2019 at 06:17:29PM +0100, Daniel P. Berrangé wrote:
> > Converting from virObject to GObject is reasonably straightforward,
> > as illustrated by this patch for virIdentity
> > 
> 
> The change would be much easier to see if this patch did not contain
> the g_autofree changes and the removal of cleanup/error labels, which
> generate a lot of churn.
> 
> > In the header file
> > 
> > - Remove
> > 
> >     typedef struct _virIdentity virIdentity
> > 
> > - Add
> > 
> >     #define VIR_TYPE_IDENTITY virIdentity_get_type ()
> >     G_DECLARE_FINAL_TYPE (virIdentity, virIdentity, VIR, IDENTITY, GObject);
> > 
> >   Which provides the typedef we just removed, and class
> >   declaration boilerplate and various other constants/macros.
> > 
> > In the source file
> > 
> > - Change 'virObject parent' to 'GObject parent' in the struct
> > - Remove the virClass variable and its initializing call
> > - Add
> > 
> >      G_DEFINE_TYPE(virIdentity, virIdentity, G_TYPE_OBJECT)
> > 
> >   which declares the instance & class constructor functions
> > 
> > - Add an impl of the instance & class constructors
> >   wiring up the finalize method to point to our dispose impl
> > 
> > In all files
> > 
> > - Replace VIR_AUTOUNREF(virIdentityPtr) with g_autoptr(virIdentity)
> > 
> 
> Is the idea to never mix VIR_ALLOC/VIR_AUTOFREE with g_alloc/g_auto*?

Functionally there shouldn't be any problem with mixing the cleanup
/ allocator APIs..

> If not, this step could be separated by temporarily setting
> virObjectUnref as the cleanup function for g_autoptr.

I'll have more of a think about separating the changes.


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

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