Skip to content

Commit 0575551

Browse files
authored
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.
1 parent 6c6a153 commit 0575551

File tree

4 files changed

+9
-12
lines changed

4 files changed

+9
-12
lines changed

Include/internal/pycore_object.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -232,15 +232,6 @@ extern void _PyObject_FreeInstanceAttributes(PyObject *self);
232232
extern int _PyObject_IsInstanceDictEmpty(PyObject *);
233233
extern PyObject* _PyType_GetSubclasses(PyTypeObject *);
234234

235-
/* This function returns the number of allocated memory blocks, regardless of size */
236-
PyAPI_FUNC(Py_ssize_t) _Py_GetAllocatedBlocks(void);
237-
238-
/* Macros */
239-
#ifdef WITH_PYMALLOC
240-
// Export the symbol for the 3rd party guppy3 project
241-
PyAPI_FUNC(int) _PyObject_DebugMallocStats(FILE *out);
242-
#endif
243-
244235
#ifdef __cplusplus
245236
}
246237
#endif

Include/internal/pycore_pymem.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ PyAPI_DATA(struct _PyTraceMalloc_Config) _Py_tracemalloc_config;
9999
void *_PyObject_VirtualAlloc(size_t size);
100100
void _PyObject_VirtualFree(void *, size_t size);
101101

102+
/* This function returns the number of allocated memory blocks, regardless of size */
103+
PyAPI_FUNC(Py_ssize_t) _Py_GetAllocatedBlocks(void);
104+
105+
/* Macros */
106+
#ifdef WITH_PYMALLOC
107+
// Export the symbol for the 3rd party guppy3 project
108+
PyAPI_FUNC(int) _PyObject_DebugMallocStats(FILE *out);
109+
#endif
102110

103111
#ifdef __cplusplus
104112
}

Objects/obmalloc.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
/* Defined in tracemalloc.c */
99
extern void _PyMem_DumpTraceback(int fd, const void *ptr);
1010

11-
// Forward declaration
12-
int _PyObject_DebugMallocStats(FILE *out);
13-
1411

1512
/* Python's malloc wrappers (see pymem.h) */
1613

Python/pylifecycle.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "pycore_pathconfig.h" // _PyConfig_WritePathConfig()
2020
#include "pycore_pyerrors.h" // _PyErr_Occurred()
2121
#include "pycore_pylifecycle.h" // _PyErr_Print()
22+
#include "pycore_pymem.h" // _PyObject_DebugMallocStats()
2223
#include "pycore_pystate.h" // _PyThreadState_GET()
2324
#include "pycore_runtime_init.h" // _PyRuntimeState_INIT
2425
#include "pycore_sliceobject.h" // _PySlice_Fini()

0 commit comments

Comments
 (0)