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

Re: [libvirt] PATCH: 1/2: port Test driver to network APIs



On Wed, Jul 02, 2008 at 10:13:00PM +0200, Jim Meyering wrote:
> >  static virNetworkPtr testNetworkCreate(virConnectPtr conn, const char *xml) {
> > -    int handle = -1;
> > -    virNetworkPtr net;
> > +    virNetworkDefPtr def;
> > +    virNetworkObjPtr net;
> >      GET_CONNECTION(conn, NULL);
> >
> > -    if (xml == NULL) {
> > -        testError(conn, NULL, NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
> > -        return (NULL);
> > -    }
> > +    if ((def = virNetworkDefParse(conn, xml, NULL)) == NULL)
> > +        return NULL;
> >
> > -    if (privconn->numNetworks == MAX_NETWORKS) {
> > -        testError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, _("too many networks"));
> > -        return (NULL);
> > -    }
> > +    if ((net = virNetworkAssignDef(conn, &privconn->networks,
> > +                                   def)) == NULL)
> 
> Don't we need to call virNetworkDefFree(def) before returning?

No need as the 'net' object holds a pointer to the 'def'

  struct _virDomainObj {
      [...snip...]

    virDomainDefPtr def; /* The current definition */
    virDomainDefPtr newDef; /* New definition to activate at shutdown */

    virDomainObjPtr next;
  };

Regards,
Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|


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