diff options
author | Iceman9 <icyff@hotmail.com> | 2015-11-11 00:19:45 +0100 |
---|---|---|
committer | Iceman9 <icyff@hotmail.com> | 2015-11-18 23:30:07 +0100 |
commit | 4d2d360fd75301d4a3cb9914872f90fbef689667 (patch) | |
tree | ed62fe894ccc50077ac4cbbe4e215b4408be9839 | |
parent | 694f628bb9bb0da4a05d279b22cdb0987e2b3203 (diff) | |
download | numpy-4d2d360fd75301d4a3cb9914872f90fbef689667.tar.gz |
BLD: Enabled building with MSVC 14.0
Reallocated free functions in mem_overlap.c
Cosmetics.
Final indent.
Added tests if pointer==NULL
Fixed indent
Fixed position of goto label.
Fixed ISO C90 violation.
Made simpler checks and removed redundant lines.
-rw-r--r-- | numpy/core/src/multiarray/mapping.c | 2 | ||||
-rw-r--r-- | numpy/core/src/private/mem_overlap.c | 25 |
2 files changed, 20 insertions, 7 deletions
diff --git a/numpy/core/src/multiarray/mapping.c b/numpy/core/src/multiarray/mapping.c index 44de1cbf2..7d0bfa822 100644 --- a/numpy/core/src/multiarray/mapping.c +++ b/numpy/core/src/multiarray/mapping.c @@ -1293,7 +1293,7 @@ _get_field_view(PyArrayObject *arr, PyObject *ind, PyArrayObject **view) PyArray_NDIM(arr), PyArray_SHAPE(arr), PyArray_STRIDES(arr), - PyArray_DATA(arr) + offset, + ((char *)PyArray_DATA(arr)) + offset, PyArray_FLAGS(arr), (PyObject *)arr); if (*view == NULL) { diff --git a/numpy/core/src/private/mem_overlap.c b/numpy/core/src/private/mem_overlap.c index 3cab83497..b2b80b4e6 100644 --- a/numpy/core/src/private/mem_overlap.c +++ b/numpy/core/src/private/mem_overlap.c @@ -479,6 +479,7 @@ NPY_VISIBILITY_HIDDEN mem_overlap_t solve_diophantine(unsigned int n, diophantine_term_t *E, npy_int64 b, Py_ssize_t max_work, int require_ub_nontrivial, npy_int64 *x) { + mem_overlap_t res; unsigned int j; for (j = 0; j < n; ++j) { @@ -535,15 +536,27 @@ solve_diophantine(unsigned int n, diophantine_term_t *E, npy_int64 b, return MEM_OVERLAP_NO; } else { - diophantine_term_t Ep[n]; - npy_int64 Epsilon[n], Gamma[n]; Py_ssize_t count = 0; + diophantine_term_t *Ep = NULL; + npy_int64 *Epsilon = NULL, *Gamma = NULL; - if (diophantine_precompute(n, E, Ep, Gamma, Epsilon)) { - return MEM_OVERLAP_OVERFLOW; + Ep = malloc(n * sizeof(diophantine_term_t)); + Epsilon = malloc(n * sizeof(npy_int64)); + Gamma = malloc(n * sizeof(npy_int64)); + if (Ep == NULL || Epsilon == NULL || Gamma == NULL) { + res = MEM_OVERLAP_ERROR; + } + else if (diophantine_precompute(n, E, Ep, Gamma, Epsilon)) { + res = MEM_OVERLAP_OVERFLOW; + } + else { + res = diophantine_dfs(n, n-1, E, Ep, Gamma, Epsilon, b, max_work, + require_ub_nontrivial, x, &count); } - return diophantine_dfs(n, n-1, E, Ep, Gamma, Epsilon, b, max_work, - require_ub_nontrivial, x, &count); + free(Ep); + free(Gamma); + free(Epsilon); + return res; } } |