From 49b536fbd35832789f429b04b5d137737205d4c1 Mon Sep 17 00:00:00 2001 From: Jim Bosch Date: Mon, 10 Dec 2012 23:32:08 -0500 Subject: [PATCH] replace non-constant array sizes with scoped_array --- libs/numpy/src/ndarray.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libs/numpy/src/ndarray.cpp b/libs/numpy/src/ndarray.cpp index 30f7213d..286819a2 100644 --- a/libs/numpy/src/ndarray.cpp +++ b/libs/numpy/src/ndarray.cpp @@ -5,6 +5,7 @@ #define BOOST_NUMPY_INTERNAL #include +#include namespace boost { @@ -209,10 +210,10 @@ python::object ndarray::scalarize() const ndarray zeros(python::tuple const & shape, dtype const & dt) { int nd = len(shape); - Py_intptr_t dims[nd]; + boost::scoped_array dims(new Py_intptr_t[nd]); for (int n=0; n(shape[n]); return ndarray(python::detail::new_reference - (PyArray_Zeros(nd, dims, detail::incref_dtype(dt), 0))); + (PyArray_Zeros(nd, dims.get(), detail::incref_dtype(dt), 0))); } ndarray zeros(int nd, Py_intptr_t const * shape, dtype const & dt) @@ -224,10 +225,10 @@ ndarray zeros(int nd, Py_intptr_t const * shape, dtype const & dt) ndarray empty(python::tuple const & shape, dtype const & dt) { int nd = len(shape); - Py_intptr_t dims[nd]; + boost::scoped_array dims(new Py_intptr_t[nd]); for (int n=0; n(shape[n]); return ndarray(python::detail::new_reference - (PyArray_Empty(nd, dims, detail::incref_dtype(dt), 0))); + (PyArray_Empty(nd, dims.get(), detail::incref_dtype(dt), 0))); } ndarray empty(int nd, Py_intptr_t const * shape, dtype const & dt)