Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2015-01-06 09:39:47 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-01-06 11:09:53 +0300
commitbf0c8e116db49379900020b5a20ba15d91b3fb9a (patch)
treec65b43084bde562dc2a08b5d88cb128f09028b6b /source/blender/python/generic/python_utildefines.h
parent9fd569a654ded46901c7f20c5fe080972cbb10d2 (diff)
PyAPI: add PyList_APPEND
This appends while giving ownership to the list, avoiding temp assignment. This matches PyList_SET_ITEM which bypasses refcount's Note, this also reduce code-size, Py_DECREF is a rather heavy macro.
Diffstat (limited to 'source/blender/python/generic/python_utildefines.h')
-rw-r--r--source/blender/python/generic/python_utildefines.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/source/blender/python/generic/python_utildefines.h b/source/blender/python/generic/python_utildefines.h
index 555ad4819eb..f7d3e7a8b4a 100644
--- a/source/blender/python/generic/python_utildefines.h
+++ b/source/blender/python/generic/python_utildefines.h
@@ -44,6 +44,14 @@ extern "C" {
* use sparingly to avoid comma operator or temp var assignment */
BLI_INLINE PyObject *Py_INCREF_RET(PyObject *op) { Py_INCREF(op); return op; }
+/* append & transfer ownership to the list, avoids inline Py_DECREF all over (which is quite a large macro) */
+BLI_INLINE int PyList_APPEND(PyObject *op, PyObject *v)
+{
+ int ret = PyList_Append(op, v);
+ Py_DecRef(v);
+ return ret;
+}
+
#ifdef __cplusplus
}
#endif