[libvirt] [PATCH v2 5/5] cpu_models: add Python bindings
Eric Blake
eblake at redhat.com
Tue Sep 10 23:53:41 UTC 2013
On 09/06/2013 05:11 PM, Giuseppe Scrivano wrote:
> Signed-off-by: Giuseppe Scrivano <gscrivan at redhat.com>
> ---
> python/generator.py | 2 +-
> python/libvirt-override-api.xml | 7 ++++++
> python/libvirt-override.c | 56 +++++++++++++++++++++++++++++++++++++++++
> python/libvirt-override.py | 11 ++++++++
> 4 files changed, 75 insertions(+), 1 deletion(-)
> +
> + len = 0;
> + for (it = models; *it; it++)
> + len++;
> +
> + if ((rv = PyList_New(len)) == NULL)
> + goto error;
> +
Again, the C return value should make it so you don't have to re-count
len via 'it' yourself.
> + len = 0;
> + for (it = models; *it; it++){
Space before {
> + PyObject *str;
> + if ((str = PyString_FromString(*it)) == NULL)
> + goto error;
> +
> + PyList_SET_ITEM(rv, len++, str);
> + }
> +
> +done:
> + if (models) {
> + for (it = models; *it; it++)
> + VIR_FREE(*it);
> + VIR_FREE(models);
> + }
> +
> + return rv;
> +
> +error:
> + rv = VIR_PY_INT_FAIL;
Ouch. Memory leak of the former value of rv.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130910/ce093002/attachment-0001.sig>
More information about the libvir-list
mailing list