[Numpy-discussion] Some questions about PyArray_As2D.
ariciputi at pito.com
Wed Dec 11 03:03:06 EST 2002
I've two question about PyArray_As2D function:
1) Looking at the source code I realized that the prototype given in
the manual is different from that of the source:
PyArray_As2D(PyObject *op, char **ptr, int *m, int *n, int type) (from
PyArray_As2D(PyObject **op, char ***ptr, int *d1, int *d2, int
typecode) (from source)
As far as I can understand the source version is correct while the
manual's one is not. Am I wrong?
2) Next in the source code I've found the following memory allocation:
data = (char **)malloc(n*sizeof(char *));
without checking if malloc return NULL or not. As far as I know it's
not safe, even if it's very unlikely that this malloc would fail.
Anyway in that case the following:
data[i] = ap->data + i*ap->strides;
would cause the function to abort. Again am I wrong?
Thanks in advance,
Andrea Riciputi <mailto:andrea.riciputi at libero.it>
"Science is like sex: sometimes something useful comes out,
but that is not the reason we are doing it" -- (Richard Feynman)
More information about the NumPy-Discussion