Commit 837400a8 authored by Joseph Weston's avatar Joseph Weston
Browse files

add comments related to use of DECREF

parent 909b30e9
Pipeline #1765 passed with stage
in 18 seconds
......@@ -1716,7 +1716,6 @@ PyObject *reduce(PyObject *self_, PyObject*)
self->ndim_shape(&ndim, &shape);
size_t size_in_bytes = calc_size(ndim, shape) * sizeof(T);
Py_INCREF(reconstruct);
PyObject *pyshape = PyTuple_New(ndim);
for (int i=0; i < ndim; ++i)
PyTuple_SET_ITEM(pyshape, i, PyInt_FromSize_t(shape[i]));
......@@ -1724,9 +1723,11 @@ PyObject *reduce(PyObject *self_, PyObject*)
PyObject *data = PyBytes_FromStringAndSize((char*)self->data(),
size_in_bytes);
// PyTuple_SET_ITEM steals references, so we need to INCREF
Py_INCREF(reconstruct);
PyTuple_SET_ITEM(result, 0, reconstruct);
// Py_BuildValue does not steal references, so we need to DECREF
PyTuple_SET_ITEM(result, 1, Py_BuildValue("(OOO)", pyshape, format, data));
Py_DECREF(pyshape);
Py_DECREF(format);
Py_DECREF(data);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment