C++ cleanup of old C conventions - prefer C++ casting to unsafe C style casts - use templates to encapsulate casting - prefer new to malloc - apply const when possible - decalare variables as near to use as possible

This commit is contained in:
dand-oss 2012-09-09 19:57:26 -05:00 committed by Siu Kwan Lam
commit db00a6b8de
3 changed files with 265 additions and 388 deletions

View file

@ -91,15 +91,14 @@ void *get_object_arg(PyObject *args)
return PyCapsule_GetPointer(o, NULL);
}
// must delete [] returned array
void **make_array_from_list(PyObject *list, int n)
{
int i;
void **arr;
arr = (void **)malloc(sizeof(void *) * n);
void **arr = new void*[n] ;
if (!arr)
return NULL;
int i;
for (i=0; i<n; i++) {
PyObject *e = PyList_GetItem(list, i);
arr[i] = PyCapsule_GetPointer(e, NULL);