Re: [PATCH v2 01/40] util: virresctrl: convert classes to GObject

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

 



On Tue, 2020-04-21 at 15:48 +0200, Rafael Fonseca wrote:
> @@ -793,21 +830,13 @@ virResctrlGetInfo(virResctrlInfoPtr resctrl)
>  virResctrlInfoPtr
>  virResctrlInfoNew(void)
>  {
> -    virResctrlInfoPtr ret = NULL;
> -
> -    if (virResctrlInitialize() < 0)
> -        return NULL;
> -
> -    ret = virObjectNew(virResctrlInfoClass);
> -    if (!ret)
> -        return NULL;
> +    g_autoptr(virResctrlInfo) ret =
> VIR_RESCTRL_INFO(g_object_new(VIR_TYPE_RESCTRL_INFO, NULL));
>  
>      if (virResctrlGetInfo(ret) < 0) {
> -        virObjectUnref(ret);
>          return NULL;
>      }
>  
> -    return ret;
> +    return g_steal_pointer(&ret);
>  }


(FYI: Glib provides a base class GInitiable (and an async variant) for
an object that requires initialization immediately after allocation and
returns NULL if said initialization fails. Not sure that it would gain
us anything here, but just thought I'd mention it.)

Jonathon




[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