summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2017-11-29 17:20:38 +0100
committerGitHub <noreply@github.com>2017-11-29 17:20:38 +0100
commit5d39e0429029324cae90bba2f19fb689b007c7d6 (patch)
treed414a4bc635c750d07c93d94835d932d3524c062 /Include/pymem.h
parenttest_socket: socket.socketpair() is always available (#4634) (diff)
downloadcpython-5d39e0429029324cae90bba2f19fb689b007c7d6.tar.gz
cpython-5d39e0429029324cae90bba2f19fb689b007c7d6.tar.bz2
cpython-5d39e0429029324cae90bba2f19fb689b007c7d6.zip
bpo-32030: Rework memory allocators (#4625)
* Fix _PyMem_SetupAllocators("debug"): always restore allocators to the defaults, rather than only caling _PyMem_SetupDebugHooks(). * Add _PyMem_SetDefaultAllocator() helper to set the "default" allocator. * Add _PyMem_GetAllocatorsName(): get the name of the allocators * main() now uses debug hooks on memory allocators if Py_DEBUG is defined, rather than calling directly malloc() * Document default memory allocators in C API documentation * _Py_InitializeCore() now fails with a fatal user error if PYTHONMALLOC value is an unknown memory allocator, instead of failing with a fatal internal error. * Add new tests on the PYTHONMALLOC environment variable * Add support.with_pymalloc() * Add the _testcapi.WITH_PYMALLOC constant and expose it as support.with_pymalloc(). * sysconfig.get_config_var('WITH_PYMALLOC') doesn't work on Windows, so replace it with support.with_pymalloc(). * pythoninfo: add _testcapi collector for pymem
Diffstat (limited to 'Include/pymem.h')
-rw-r--r--Include/pymem.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/Include/pymem.h b/Include/pymem.h
index 57a34cf9078..09d15020e0e 100644
--- a/Include/pymem.h
+++ b/Include/pymem.h
@@ -21,6 +21,9 @@ PyAPI_FUNC(void) PyMem_RawFree(void *ptr);
allocators. */
PyAPI_FUNC(int) _PyMem_SetupAllocators(const char *opt);
+/* Try to get the allocators name set by _PyMem_SetupAllocators(). */
+PyAPI_FUNC(const char*) _PyMem_GetAllocatorsName(void);
+
#ifdef WITH_PYMALLOC
PyAPI_FUNC(int) _PyMem_PymallocEnabled(void);
#endif
@@ -230,7 +233,12 @@ PyAPI_FUNC(void) PyMem_SetupDebugHooks(void);
#endif
#ifdef Py_BUILD_CORE
-PyAPI_FUNC(void) _PyMem_GetDefaultRawAllocator(PyMemAllocatorEx *alloc);
+/* Set the memory allocator of the specified domain to the default.
+ Save the old allocator into *old_alloc if it's non-NULL.
+ Return on success, or return -1 if the domain is unknown. */
+PyAPI_FUNC(int) _PyMem_SetDefaultAllocator(
+ PyMemAllocatorDomain domain,
+ PyMemAllocatorEx *old_alloc);
#endif
#ifdef __cplusplus