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:
parent
47baa49160
commit
db00a6b8de
3 changed files with 265 additions and 388 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue