diff options
| author | Sebastian Berg <sebastianb@nvidia.com> | 2023-02-21 12:09:17 +0100 |
|---|---|---|
| committer | Sebastian Berg <sebastianb@nvidia.com> | 2023-02-21 12:09:17 +0100 |
| commit | cafd35cf47ba6fc677d4a4136d810cbc3c00faf0 (patch) | |
| tree | bb2e463ceb96a268c1c85f748e3aa327836cba81 /numpy | |
| parent | 9a7f46a8d7abbd68e22c471d80cf00774e906967 (diff) | |
| download | numpy-cafd35cf47ba6fc677d4a4136d810cbc3c00faf0.tar.gz | |
MAINT: Simplify temporary dimensions by using static array
Using maxdims for this is the typical pattern in NumPy and avoids the
malloc call.
Diffstat (limited to 'numpy')
| -rw-r--r-- | numpy/fft/_pocketfft.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/numpy/fft/_pocketfft.c b/numpy/fft/_pocketfft.c index d7090cd61..37649386f 100644 --- a/numpy/fft/_pocketfft.c +++ b/numpy/fft/_pocketfft.c @@ -2232,6 +2232,8 @@ execute_real_forward(PyObject *a1, double fct) { rfft_plan plan=NULL; int fail = 0; + npy_intp tdim[NPY_MAXDIMS]; + PyArrayObject *data = (PyArrayObject *)PyArray_FromAny(a1, PyArray_DescrFromType(NPY_DOUBLE), 1, 0, NPY_ARRAY_DEFAULT | NPY_ARRAY_ENSUREARRAY | NPY_ARRAY_FORCECAST, @@ -2241,15 +2243,11 @@ execute_real_forward(PyObject *a1, double fct) int ndim = PyArray_NDIM(data); const npy_intp *odim = PyArray_DIMS(data); int npts = odim[ndim - 1]; - npy_intp *tdim=(npy_intp *)malloc(ndim*sizeof(npy_intp)); - if (!tdim) - { Py_XDECREF(data); return NULL; } for (int d=0; d<ndim-1; ++d) tdim[d] = odim[d]; tdim[ndim-1] = npts/2 + 1; PyArrayObject *ret = (PyArrayObject *)PyArray_Empty(ndim, tdim, PyArray_DescrFromType(NPY_CDOUBLE), 0); - free(tdim); if (!ret) fail=1; if (!fail) { int rstep = PyArray_DIM(ret, PyArray_NDIM(ret) - 1)*2; |
