summaryrefslogtreecommitdiffstats
path: root/Objects/object.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-02-05 00:11:10 (GMT)
committerGitHub <noreply@github.com>2020-02-05 00:11:10 (GMT)
commit40e547dfbb9052ca0c667b242f6825ed1c23c195 (patch)
treeaebb9f8925156ed5a97bbd0daddb43e4c03e2839 /Objects/object.c
parent2545fa87628b4caca519da8aeb0eeef368b9dc0d (diff)
downloadcpython-40e547dfbb9052ca0c667b242f6825ed1c23c195.zip
cpython-40e547dfbb9052ca0c667b242f6825ed1c23c195.tar.gz
cpython-40e547dfbb9052ca0c667b242f6825ed1c23c195.tar.bz2
bpo-39542: Make _Py_NewReference() opaque in C API (GH-18346)
_Py_NewReference() becomes a regular opaque function, rather than a static inline function in the C API (object.h), to better hide implementation details. Move _Py_tracemalloc_config from public pymem.h to internal pycore_pymem.h header. Make _Py_AddToAllObjects() private.
Diffstat (limited to 'Objects/object.c')
-rw-r--r--Objects/object.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/Objects/object.c b/Objects/object.c
index 085605a..e6bfad4 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -93,7 +93,7 @@ static PyObject refchain = {&refchain, &refchain};
* way, though; exceptions include statically allocated type objects, and
* statically allocated singletons (like Py_True and Py_None).
*/
-void
+static void
_Py_AddToAllObjects(PyObject *op, int force)
{
#ifdef Py_DEBUG
@@ -1805,6 +1805,22 @@ _PyTypes_Init(void)
}
+void
+_Py_NewReference(PyObject *op)
+{
+ if (_Py_tracemalloc_config.tracing) {
+ _PyTraceMalloc_NewReference(op);
+ }
+#ifdef Py_REF_DEBUG
+ _Py_RefTotal++;
+#endif
+ Py_REFCNT(op) = 1;
+#ifdef Py_TRACE_REFS
+ _Py_AddToAllObjects(op, 1);
+#endif
+}
+
+
#ifdef Py_TRACE_REFS
void
_Py_ForgetReference(PyObject *op)