summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2017-12-06 16:26:10 (GMT)
committerGitHub <noreply@github.com>2017-12-06 16:26:10 (GMT)
commit6bf992a1ac6f3f4d0f83ead9c6403a76afdbe6eb (patch)
tree592a2085a4d49a5fc394e96b4e3b57d25d82b38a /Objects
parent672b6baa71010f236ee8c8ce912e98cb542385c6 (diff)
downloadcpython-6bf992a1ac6f3f4d0f83ead9c6403a76afdbe6eb.zip
cpython-6bf992a1ac6f3f4d0f83ead9c6403a76afdbe6eb.tar.gz
cpython-6bf992a1ac6f3f4d0f83ead9c6403a76afdbe6eb.tar.bz2
bpo-32030: Add pymain_get_global_config() (#4735)
* Py_Main() now starts by reading Py_xxx configuration variables to only work on its own private structure, and then later writes back the configuration into these variables. * Replace Py_GETENV() with pymain_get_env_var() which ignores empty variables. * Add _PyCoreConfig.dump_refs * Add _PyCoreConfig.malloc_stats * _PyObject_DebugMallocStats() is now responsible to check if debug hooks are installed. The function returns 1 if stats were written, or 0 if the hooks are disabled. Mark _PyMem_PymallocEnabled() as static.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/obmalloc.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/Objects/obmalloc.c b/Objects/obmalloc.c
index 7911028..c065541 100644
--- a/Objects/obmalloc.c
+++ b/Objects/obmalloc.c
@@ -379,7 +379,7 @@ _PyMem_DebugEnabled(void)
return (_PyObject.malloc == _PyMem_DebugMalloc);
}
-int
+static int
_PyMem_PymallocEnabled(void)
{
if (_PyMem_DebugEnabled()) {
@@ -2467,10 +2467,17 @@ pool_is_in_list(const poolp target, poolp list)
/* Print summary info to "out" about the state of pymalloc's structures.
* In Py_DEBUG mode, also perform some expensive internal consistency
* checks.
+ *
+ * Return 0 if the memory debug hooks are not installed or no statistics was
+ * writen into out, return 1 otherwise.
*/
-void
+int
_PyObject_DebugMallocStats(FILE *out)
{
+ if (!_PyMem_PymallocEnabled()) {
+ return 0;
+ }
+
uint i;
const uint numclasses = SMALL_REQUEST_THRESHOLD >> ALIGNMENT_SHIFT;
/* # of pools, allocated blocks, and free blocks per class index */
@@ -2603,6 +2610,7 @@ _PyObject_DebugMallocStats(FILE *out)
total += printone(out, "# bytes lost to quantization", quantization);
total += printone(out, "# bytes lost to arena alignment", arena_alignment);
(void)printone(out, "Total", total);
+ return 1;
}
#endif /* #ifdef WITH_PYMALLOC */