From 76db3ffb4b8e8a1031133a9a747310b8639890a0 Mon Sep 17 00:00:00 2001 From: Julian Taylor Date: Thu, 3 Oct 2013 23:01:27 +0200 Subject: 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. --- numpy/lib/src/_compiled_base.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'numpy/lib/src/_compiled_base.c') 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; } -- cgit v1.2.1