summaryrefslogtreecommitdiffstats
path: root/Objects/obmalloc.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2017-11-16 11:20:31 (GMT)
committerGitHub <noreply@github.com>2017-11-16 11:20:31 (GMT)
commitccb0442a338066bf40fe417455e5a374e5238afb (patch)
tree155b84289b5136d624ebd3577902ee1435a6b4e1 /Objects/obmalloc.c
parent05cb728d68a278d11466f9a6c8258d914135c96c (diff)
downloadcpython-ccb0442a338066bf40fe417455e5a374e5238afb.zip
cpython-ccb0442a338066bf40fe417455e5a374e5238afb.tar.gz
cpython-ccb0442a338066bf40fe417455e5a374e5238afb.tar.bz2
bpo-32043: New "developer mode": "-X dev" option (#4413)
Add a new "developer mode": new "-X dev" command line option to enable debug checks at runtime. Changes: * Add unit tests for -X dev * test_cmd_line: replace test.support with support. * Fix _PyRuntimeState_Fini(): Use the same memory allocator than _PyRuntimeState_Init(). * Fix _PyMem_GetDefaultRawAllocator()
Diffstat (limited to 'Objects/obmalloc.c')
-rw-r--r--Objects/obmalloc.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/Objects/obmalloc.c b/Objects/obmalloc.c
index 699cce9..7c6973e 100644
--- a/Objects/obmalloc.c
+++ b/Objects/obmalloc.c
@@ -190,8 +190,14 @@ static struct {
void
_PyMem_GetDefaultRawAllocator(PyMemAllocatorEx *alloc_p)
{
- PyMemAllocatorEx alloc = {NULL, PYRAW_FUNCS};
- *alloc_p = alloc;
+ PyMemAllocatorEx pymem_raw = {
+#ifdef Py_DEBUG
+ &_PyMem_Debug.raw, PYRAWDBG_FUNCS
+#else
+ NULL, PYRAW_FUNCS
+#endif
+ };
+ *alloc_p = pymem_raw;
}
int
@@ -274,13 +280,6 @@ _PyObject_Initialize(struct _pyobj_runtime_state *state)
void
_PyMem_Initialize(struct _pymem_runtime_state *state)
{
- PyMemAllocatorEx pymem_raw = {
-#ifdef Py_DEBUG
- &_PyMem_Debug.raw, PYRAWDBG_FUNCS
-#else
- NULL, PYRAW_FUNCS
-#endif
- };
PyMemAllocatorEx pymem = {
#ifdef Py_DEBUG
&_PyMem_Debug.mem, PYDBG_FUNCS
@@ -296,7 +295,7 @@ _PyMem_Initialize(struct _pymem_runtime_state *state)
#endif
};
- state->allocators.raw = pymem_raw;
+ _PyMem_GetDefaultRawAllocator(&state->allocators.raw);
state->allocators.mem = pymem;
state->allocators.obj = pyobject;