From: Travis O. <oli...@ee...> - 2002-04-11 22:44:34
|
> Looking at the code to PyArray_Free, I agree with Chris. Called to > free a 2D > array, I think that PyArray_Free leaks all of the row storage because > ap->nd == 2, not 3: > > * {%c++%} */ > extern int PyArray_Free(PyObject *op, char *ptr) { > PyArrayObject *ap = (PyArrayObject *)op; > int i, n; > > if (ap->nd > 2) return -1; > if (ap->nd == 3) { > n = ap->dimensions[0]; > for (i=0; i<n; i++) { > free(((char **)ptr)[i]); > } > } > if (ap->nd >= 2) { > free(ptr); > } > Py_DECREF(ap); > return 0; > } > /* {%c++%} */ > > This has been broken since the beginning. I believe the documentation says as much. I've never used it because I always think of 2-D arrays as a block of data not as rows of pointers. It should be fixed, but no one's ever been interested enough to do it. -Travis Oliphant |