diff options
author | Julian Taylor <jtaylor.debian@googlemail.com> | 2013-10-03 23:01:27 +0200 |
---|---|---|
committer | Julian Taylor <jtaylor.debian@googlemail.com> | 2013-10-03 23:32:09 +0200 |
commit | 76db3ffb4b8e8a1031133a9a747310b8639890a0 (patch) | |
tree | 613fad654550125b5612bc5af0ba812ba728bcc7 /numpy/lib/src | |
parent | f665c617065ba59b1c517b8dd44080c83dbfd5bd (diff) | |
download | numpy-76db3ffb4b8e8a1031133a9a747310b8639890a0.tar.gz |
MAINT: accept NULL in NpyIter_Deallocate and remove redundant NULL checks
Deallocation should just do nothing if provided a NULL pointer nditer
deletion broke this convention.
Removed many redundant NULL checks for various deallocation functions
used in numpy, they all end up in standard C free or PyMem_Free which
are both NULL safe.
Diffstat (limited to 'numpy/lib/src')
-rw-r--r-- | numpy/lib/src/_compiled_base.c | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/numpy/lib/src/_compiled_base.c b/numpy/lib/src/_compiled_base.c index 66a765868..328fc2d14 100644 --- a/numpy/lib/src/_compiled_base.c +++ b/numpy/lib/src/_compiled_base.c @@ -980,12 +980,8 @@ fail: for (i = 0; i < dimensions.len; ++i) { Py_XDECREF(op[i]); } - if (dimensions.ptr) { - PyDimMem_FREE(dimensions.ptr); - } - if (iter != NULL) { - NpyIter_Deallocate(iter); - } + PyDimMem_FREE(dimensions.ptr); + NpyIter_Deallocate(iter); return NULL; } @@ -1247,12 +1243,8 @@ fail: Py_XDECREF(ret_arr); Py_XDECREF(dtype); Py_XDECREF(indices); - if (dimensions.ptr) { - PyDimMem_FREE(dimensions.ptr); - } - if (iter != NULL) { - NpyIter_Deallocate(iter); - } + PyDimMem_FREE(dimensions.ptr); + NpyIter_Deallocate(iter); return NULL; } |