[Python-checkins] bpo-40170: Move _Py_GetAllocatedBlocks() to pycore_pymem.h (GH-30943)
vstinner
webhook-mailer at python.org
Thu Jan 27 15:23:38 EST 2022
https://github.com/python/cpython/commit/0575551f69ba9c999835bfb176a543d468083c03
commit: 0575551f69ba9c999835bfb176a543d468083c03
branch: main
author: Victor Stinner <vstinner at python.org>
committer: vstinner <vstinner at python.org>
date: 2022-01-27T21:23:22+01:00
summary:
bpo-40170: Move _Py_GetAllocatedBlocks() to pycore_pymem.h (GH-30943)
Move _Py_GetAllocatedBlocks() and _PyObject_DebugMallocStats()
declarations to pycore_pymem.h. These functions are related to memory
allocators, not to the PyObject structure.
files:
M Include/internal/pycore_object.h
M Include/internal/pycore_pymem.h
M Objects/obmalloc.c
M Python/pylifecycle.c
diff --git a/Include/internal/pycore_object.h b/Include/internal/pycore_object.h
index c520122aa579b..5fe4ddb2efbe1 100644
--- a/Include/internal/pycore_object.h
+++ b/Include/internal/pycore_object.h
@@ -232,15 +232,6 @@ extern void _PyObject_FreeInstanceAttributes(PyObject *self);
extern int _PyObject_IsInstanceDictEmpty(PyObject *);
extern PyObject* _PyType_GetSubclasses(PyTypeObject *);
-/* This function returns the number of allocated memory blocks, regardless of size */
-PyAPI_FUNC(Py_ssize_t) _Py_GetAllocatedBlocks(void);
-
-/* Macros */
-#ifdef WITH_PYMALLOC
-// Export the symbol for the 3rd party guppy3 project
-PyAPI_FUNC(int) _PyObject_DebugMallocStats(FILE *out);
-#endif
-
#ifdef __cplusplus
}
#endif
diff --git a/Include/internal/pycore_pymem.h b/Include/internal/pycore_pymem.h
index d70deee710e30..b9eea9d4b30ad 100644
--- a/Include/internal/pycore_pymem.h
+++ b/Include/internal/pycore_pymem.h
@@ -99,6 +99,14 @@ PyAPI_DATA(struct _PyTraceMalloc_Config) _Py_tracemalloc_config;
void *_PyObject_VirtualAlloc(size_t size);
void _PyObject_VirtualFree(void *, size_t size);
+/* This function returns the number of allocated memory blocks, regardless of size */
+PyAPI_FUNC(Py_ssize_t) _Py_GetAllocatedBlocks(void);
+
+/* Macros */
+#ifdef WITH_PYMALLOC
+// Export the symbol for the 3rd party guppy3 project
+PyAPI_FUNC(int) _PyObject_DebugMallocStats(FILE *out);
+#endif
#ifdef __cplusplus
}
diff --git a/Objects/obmalloc.c b/Objects/obmalloc.c
index ea0faff5bbe30..e3df7e8cc410e 100644
--- a/Objects/obmalloc.c
+++ b/Objects/obmalloc.c
@@ -8,9 +8,6 @@
/* Defined in tracemalloc.c */
extern void _PyMem_DumpTraceback(int fd, const void *ptr);
-// Forward declaration
-int _PyObject_DebugMallocStats(FILE *out);
-
/* Python's malloc wrappers (see pymem.h) */
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index 106e11ea12ff5..ba7bcd2f8899e 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -19,6 +19,7 @@
#include "pycore_pathconfig.h" // _PyConfig_WritePathConfig()
#include "pycore_pyerrors.h" // _PyErr_Occurred()
#include "pycore_pylifecycle.h" // _PyErr_Print()
+#include "pycore_pymem.h" // _PyObject_DebugMallocStats()
#include "pycore_pystate.h" // _PyThreadState_GET()
#include "pycore_runtime_init.h" // _PyRuntimeState_INIT
#include "pycore_sliceobject.h" // _PySlice_Fini()
More information about the Python-checkins
mailing list