summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2007-12-11 21:57:29 +0000
committerJim Meyering <meyering@redhat.com>2007-12-11 21:57:29 +0000
commit7ab08c13e22fb8375be37107bcbf2b5fee35f0d0 (patch)
tree12535ac81b8bfc0a3945a651a7694aa89d46981c
parente4ad2aee2906b37d29ae87d5ba27973ae0684d80 (diff)
downloadlibvirt-python-v6-7ab08c13e22fb8375be37107bcbf2b5fee35f0d0.tar.gz
libvirt-python-v6-7ab08c13e22fb8375be37107bcbf2b5fee35f0d0.tar.xz
libvirt-python-v6-7ab08c13e22fb8375be37107bcbf2b5fee35f0d0.zip
Use a variable name as sizeof argument, not a type name.
Given code like: T *var = calloc (n, sizeof (T)); Convert to this: T *var = calloc (n, sizeof (*var)); This first-cut change adjusts all malloc, calloc, and realloc statements. The only binary differences are in remote_internal.c (due to the bug fix) and in xmlrpc.c (due to factorization). * python/libvir.c: As above. * qemud/event.c: Likewise. * qemud/mdns.c: Likewise. * qemud/qemud.c: Likewise. * qemud/remote.c: Likewise. * src/bridge.c: Likewise. * src/buf.c: Likewise. * src/conf.c: Likewise. * src/hash.c: Likewise. * src/iptables.c: Likewise. * src/openvz_conf.c: Likewise. * src/qemu_conf.c: Likewise. * src/qemu_driver.c: Likewise. * src/test.c: Likewise. * src/xen_internal.c: Likewise. * src/xen_unified.c: Likewise. * src/xm_internal.c: Likewise. * src/xml.c: Likewise. * tests/qemuxml2argvtest.c: Likewise. * src/xmlrpc.c (xmlRpcValuePtr): Likewise, and minor factorization. * src/remote_internal.c (remoteAuthMakeCredentials): Use the right type when allocating space for an array of cred _pointers_.
-rw-r--r--libvir.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/libvir.c b/libvir.c
index 0edec41..3b41dc1 100644
--- a/libvir.c
+++ b/libvir.c
@@ -347,7 +347,7 @@ libvirt_virConnectOpenAuth(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
auth.ncredtype = PyList_Size(pycredtype);
if (auth.ncredtype) {
int i;
- auth.credtype = malloc(sizeof(int) * auth.ncredtype);
+ auth.credtype = malloc(sizeof(*auth.credtype) * auth.ncredtype);
if (auth.credtype == NULL) {
Py_INCREF(Py_None);
return (Py_None);
@@ -490,7 +490,7 @@ libvirt_virConnectListDefinedDomains(PyObject *self ATTRIBUTE_UNUSED,
}
if (c_retval) {
- names = malloc(sizeof(char *) * c_retval);
+ names = malloc(sizeof(*names) * c_retval);
if (!names) {
Py_INCREF(Py_None);
return (Py_None);
@@ -670,7 +670,7 @@ libvirt_virConnectListNetworks(PyObject *self ATTRIBUTE_UNUSED,
}
if (c_retval) {
- names = malloc(sizeof(char *) * c_retval);
+ names = malloc(sizeof(*names) * c_retval);
if (!names) {
Py_INCREF(Py_None);
return (Py_None);
@@ -717,7 +717,7 @@ libvirt_virConnectListDefinedNetworks(PyObject *self ATTRIBUTE_UNUSED,
}
if (c_retval) {
- names = malloc(sizeof(char *) * c_retval);
+ names = malloc(sizeof(*names) * c_retval);
if (!names) {
Py_INCREF(Py_None);
return (Py_None);
@@ -863,8 +863,8 @@ PyObject * libvirt_virNodeGetCellsFreeMemory(PyObject *self ATTRIBUTE_UNUSED,
goto error;
conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
- freeMems = (unsigned long long *)
- malloc(maxCells * sizeof(unsigned long long));
+ freeMems =
+ malloc(maxCells * sizeof(*freeMems));
if (freeMems == NULL)
goto error;