History

python/ext/py-source.c: use PyArray_NewShape, not _Resize

Paul Brossier committed 9 years ago

Commit 8b7cdba1 parent 410a1571 file · +5 −3Browse files

Showing the changes to python (1 of 1 file). Show all

Unified · Split

python/ext/py-source.c+5−3
@@ -310,9 +310,10 @@ static PyObject* Pyaubio_source_iter_next(Py_source *self) { · 309 unmodified lines
310310 PyObject *vec = PyTuple_GetItem(done, 0);
311311 return vec;
312312 } else if (PyLong_AsLong(size) > 0) {
313− // short read
313+ // short read, return a shorter array
314314 PyArrayObject *shortread = (PyArrayObject*)PyTuple_GetItem(done, 0);
315315 PyArray_Dims newdims;
316+ PyObject *reshaped;
316317 newdims.len = PyArray_NDIM(shortread);
317318 newdims.ptr = PyArray_DIMS(shortread);
318319 // mono or multiple channels?
@@ -321,8 +322,9 @@ static PyObject* Pyaubio_source_iter_next(Py_source *self) { · 2 unmodified lines
321322 } else {
322323 newdims.ptr[1] = PyLong_AsLong(size);
323324 }
324− PyArray_Resize(shortread, &newdims, 1, NPY_ANYORDER);
325− return (PyObject*)shortread;
325+ reshaped = PyArray_Newshape(shortread, &newdims, NPY_CORDER);
326+ Py_DECREF(shortread);
327+ return reshaped;
326328 } else {
327329 PyErr_SetNone(PyExc_StopIteration);
328330 return NULL;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t