summaryrefslogtreecommitdiff
path: root/Modules/main.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2019-03-06 01:13:43 +0100
committerGitHub <noreply@github.com>2019-03-06 01:13:43 +0100
commitc656e25667c9acc0d13e5bb16d3df2938d0f614b (patch)
tree61e424b53e6f0b1f5a2d7637fedf47ab5e91962e /Modules/main.c
parent7d2ef3ef5042356aaeaf832ad4204b7dad2e1b8c (diff)
downloadcpython-git-c656e25667c9acc0d13e5bb16d3df2938d0f614b.tar.gz
bpo-36142: Add _PyPreConfig_SetAllocator() (GH-12187)
* _PyPreConfig_Write() now reallocates the pre-configuration with the new memory allocator. * It is no longer needed to force the "default raw memory allocator" to clear pre-configuration and core configuration. Simplify the code. * _PyPreConfig_Write() now does nothing if called after Py_Initialize(): no longer check if the allocator is the same. * Remove _PyMem_GetDebugAllocatorsName(): dev mode sets again allocator to "debug".
Diffstat (limited to 'Modules/main.c')
-rw-r--r--Modules/main.c25
1 files changed, 2 insertions, 23 deletions
diff --git a/Modules/main.c b/Modules/main.c
index 9a2347e2b2..14055c8101 100644
--- a/Modules/main.c
+++ b/Modules/main.c
@@ -289,17 +289,9 @@ _PyMainInterpreterConfig_Read(_PyMainInterpreterConfig *main_config,
static _PyInitError
preconfig_read_write(_PyPreConfig *config, const _PyArgv *args)
{
- _PyInitError err;
-
- PyMemAllocatorEx old_alloc;
- _PyMem_SetDefaultAllocator(PYMEM_DOMAIN_RAW, &old_alloc);
-
_PyPreConfig_GetGlobalConfig(config);
- err = _PyPreConfig_ReadFromArgv(config, args);
-
- PyMem_SetAllocator(PYMEM_DOMAIN_RAW, &old_alloc);
-
+ _PyInitError err = _PyPreConfig_ReadFromArgv(config, args);
if (_Py_INIT_FAILED(err)) {
return err;
}
@@ -312,17 +304,9 @@ static _PyInitError
config_read_write(_PyCoreConfig *config, const _PyArgv *args,
const _PyPreConfig *preconfig)
{
- _PyInitError err;
-
- PyMemAllocatorEx old_alloc;
- _PyMem_SetDefaultAllocator(PYMEM_DOMAIN_RAW, &old_alloc);
-
_PyCoreConfig_GetGlobalConfig(config);
- err = _PyCoreConfig_ReadFromArgv(config, args, preconfig);
-
- PyMem_SetAllocator(PYMEM_DOMAIN_RAW, &old_alloc);
-
+ _PyInitError err = _PyCoreConfig_ReadFromArgv(config, args, preconfig);
if (_Py_INIT_FAILED(err)) {
return err;
}
@@ -355,7 +339,6 @@ static _PyInitError
pymain_init(const _PyArgv *args, PyInterpreterState **interp_p)
{
_PyInitError err;
- PyMemAllocatorEx old_alloc;
err = _PyRuntime_Initialize();
if (_Py_INIT_FAILED(err)) {
@@ -402,12 +385,8 @@ pymain_init(const _PyArgv *args, PyInterpreterState **interp_p)
err = _Py_INIT_OK();
done:
- _PyMem_SetDefaultAllocator(PYMEM_DOMAIN_RAW, &old_alloc);
-
_PyPreConfig_Clear(preconfig);
_PyCoreConfig_Clear(config);
-
- PyMem_SetAllocator(PYMEM_DOMAIN_RAW, &old_alloc);
return err;
}