On Wed, Nov 15, 2006 at 04:57:23AM -0500, Daniel Veillard wrote: > On Wed, Nov 15, 2006 at 02:20:33AM +0000, Daniel P. Berrange wrote: > > The attached patch implements the virListDefinedDomains method in the python > > bindings, since it wasn't being automatically generated by the generator.py > > script. > > > + c_retval = virConnectNumOfDefinedDomains(conn); > > + if (c_retval < 0) { > > + Py_INCREF(Py_None); > > + return (Py_None); > > + } > > + > > + if (c_retval) { > > + names = malloc(sizeof(char *) * c_retval); > > Miss NULL return check here I think. Good catch! > > > + c_retval = virConnectListDefinedDomains(conn, names, c_retval); > > + if (c_retval < 0) { > > + free(names); > > + Py_INCREF(Py_None); > > + return(Py_None); > > + } > > + } > > + py_retval = PyList_New(c_retval); > > the paranoid in me would feel safer if the for loop was protected by > a test for names not being NULL even if I agree it's not strictly needed :-) > > > + for (i = 0;i < c_retval;i++) { > > + PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(names[i])); > > + free(names[i]); > > + } Yeah, worth doing the extra check - never know when someone might do a 'trivial' code rearrangement & break my current asusmption. Dan. -- |=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|