]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-40170: Remove _Py_GetAllocatedBlocks() function (GH-30940)
authorVictor Stinner <vstinner@python.org>
Thu, 27 Jan 2022 02:35:51 +0000 (03:35 +0100)
committerGitHub <noreply@github.com>
Thu, 27 Jan 2022 02:35:51 +0000 (03:35 +0100)
Move _Py_GetAllocatedBlocks() and _PyObject_DebugMallocStats()
private functions to the internal C API.

Include/cpython/objimpl.h
Include/internal/pycore_object.h
Misc/NEWS.d/next/C API/2022-01-27-02-37-18.bpo-40170.XxQB0i.rst [new file with mode: 0644]
Objects/obmalloc.c

index 7fff96e8eb27f2f625f847fed4fe87b2b25b27bf..d7c76eab5c7312e4126af6ef5e773dc7cdaaf887 100644 (file)
    the 1st step is performed automatically for you, so in a C++ class
    constructor you would start directly with PyObject_Init/InitVar. */
 
-/* This function returns the number of allocated memory blocks, regardless of size */
-PyAPI_FUNC(Py_ssize_t) _Py_GetAllocatedBlocks(void);
-
-/* Macros */
-#ifdef WITH_PYMALLOC
-PyAPI_FUNC(int) _PyObject_DebugMallocStats(FILE *out);
-#endif
-
 
 typedef struct {
     /* user context passed as the first argument to the 2 functions */
index 5fe4ddb2efbe1e87c20fe1f7903dd9e5bff3d622..c520122aa579b9013c49a746d5f96e7e32589ddf 100644 (file)
@@ -232,6 +232,15 @@ 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/Misc/NEWS.d/next/C API/2022-01-27-02-37-18.bpo-40170.XxQB0i.rst b/Misc/NEWS.d/next/C API/2022-01-27-02-37-18.bpo-40170.XxQB0i.rst
new file mode 100644 (file)
index 0000000..7b74382
--- /dev/null
@@ -0,0 +1,2 @@
+Move _Py_GetAllocatedBlocks() and _PyObject_DebugMallocStats() private
+functions to the internal C API. Patch by Victor Stinner.
index 4e17bf44b4e96530a4296c85233a7fbf88952968..ea0faff5bbe30d2ef6a65eff1c79bc9cc7319ed5 100644 (file)
@@ -8,6 +8,9 @@
 /* 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) */
 
@@ -1569,8 +1572,9 @@ new_arena(void)
         const char *opt = Py_GETENV("PYTHONMALLOCSTATS");
         debug_stats = (opt != NULL && *opt != '\0');
     }
-    if (debug_stats)
+    if (debug_stats) {
         _PyObject_DebugMallocStats(stderr);
+    }
 
     if (unused_arena_objects == NULL) {
         uint i;