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

Daniel P. Berrange berrange at redhat.com
Thu Jul 3 10:12:22 UTC 2008


On Thu, Jul 03, 2008 at 12:09:37PM +0200, Jim Meyering wrote:
> "Daniel P. Berrange" <berrange at redhat.com> wrote:
> > 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 ((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'
> 
> But inside that if-block (where the function returns), "net" is NULL.

Oh, I see what you mean - I didn't realize you were referring to the
failure path there. Yes, I need to free it.


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




More information about the libvir-list mailing list