Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Joseph Weston
tinyarray
Commits
837400a8
Commit
837400a8
authored
Dec 17, 2016
by
Joseph Weston
Browse files
add comments related to use of DECREF
parent
909b30e9
Pipeline
#1765
passed with stage
in 18 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/array.cc
View file @
837400a8
...
@@ -1716,7 +1716,6 @@ PyObject *reduce(PyObject *self_, PyObject*)
...
@@ -1716,7 +1716,6 @@ PyObject *reduce(PyObject *self_, PyObject*)
self
->
ndim_shape
(
&
ndim
,
&
shape
);
self
->
ndim_shape
(
&
ndim
,
&
shape
);
size_t
size_in_bytes
=
calc_size
(
ndim
,
shape
)
*
sizeof
(
T
);
size_t
size_in_bytes
=
calc_size
(
ndim
,
shape
)
*
sizeof
(
T
);
Py_INCREF
(
reconstruct
);
PyObject
*
pyshape
=
PyTuple_New
(
ndim
);
PyObject
*
pyshape
=
PyTuple_New
(
ndim
);
for
(
int
i
=
0
;
i
<
ndim
;
++
i
)
for
(
int
i
=
0
;
i
<
ndim
;
++
i
)
PyTuple_SET_ITEM
(
pyshape
,
i
,
PyInt_FromSize_t
(
shape
[
i
]));
PyTuple_SET_ITEM
(
pyshape
,
i
,
PyInt_FromSize_t
(
shape
[
i
]));
...
@@ -1724,9 +1723,11 @@ PyObject *reduce(PyObject *self_, PyObject*)
...
@@ -1724,9 +1723,11 @@ PyObject *reduce(PyObject *self_, PyObject*)
PyObject
*
data
=
PyBytes_FromStringAndSize
((
char
*
)
self
->
data
(),
PyObject
*
data
=
PyBytes_FromStringAndSize
((
char
*
)
self
->
data
(),
size_in_bytes
);
size_in_bytes
);
// PyTuple_SET_ITEM steals references, so we need to INCREF
Py_INCREF
(
reconstruct
);
PyTuple_SET_ITEM
(
result
,
0
,
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
));
PyTuple_SET_ITEM
(
result
,
1
,
Py_BuildValue
(
"(OOO)"
,
pyshape
,
format
,
data
));
Py_DECREF
(
pyshape
);
Py_DECREF
(
pyshape
);
Py_DECREF
(
format
);
Py_DECREF
(
format
);
Py_DECREF
(
data
);
Py_DECREF
(
data
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment