summaryrefslogtreecommitdiffstats
path: root/Include/object.h
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-02-07 00:24:29 (GMT)
committerGitHub <noreply@github.com>2020-02-07 00:24:29 (GMT)
commitc86a11221df7e37da389f9c6ce6e47ea22dc44ff (patch)
treec27a35a01bde1554488268dd3bbeb8b4c46e193c /Include/object.h
parenta93c51e3a8e15f1a486d11d5b55a64f3381babe0 (diff)
downloadcpython-c86a11221df7e37da389f9c6ce6e47ea22dc44ff.zip
cpython-c86a11221df7e37da389f9c6ce6e47ea22dc44ff.tar.gz
cpython-c86a11221df7e37da389f9c6ce6e47ea22dc44ff.tar.bz2
bpo-39573: Add Py_SET_REFCNT() function (GH-18389)
Add a Py_SET_REFCNT() function to set the reference counter of an object.
Diffstat (limited to 'Include/object.h')
-rw-r--r--Include/object.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/Include/object.h b/Include/object.h
index 38794a0..0b63051 100644
--- a/Include/object.h
+++ b/Include/object.h
@@ -123,6 +123,11 @@ typedef struct {
#define Py_TYPE(ob) (_PyObject_CAST(ob)->ob_type)
#define Py_SIZE(ob) (_PyVarObject_CAST(ob)->ob_size)
+static inline void _Py_SET_REFCNT(PyObject *ob, Py_ssize_t refcnt) {
+ ob->ob_refcnt = refcnt;
+}
+#define Py_SET_REFCNT(ob, refcnt) _Py_SET_REFCNT(_PyObject_CAST(ob), refcnt)
+
/*
Type objects contain a string containing the type name (to help somewhat
in debugging), the allocation parameters (see PyObject_New() and