]> granicus.if.org Git - python/commitdiff
bpo-35081: Move Py_BUILD_CORE code to internal/mem.h (GH-10249)
authorVictor Stinner <vstinner@redhat.com>
Wed, 31 Oct 2018 19:19:24 +0000 (20:19 +0100)
committerGitHub <noreply@github.com>
Wed, 31 Oct 2018 19:19:24 +0000 (20:19 +0100)
* Add #include "internal/mem.h" to C files using
  _PyMem_SetDefaultAllocator().
* Include/internal/mem.h now requires Py_BUILD_CORE to be defined.

Include/internal/mem.h
Include/pymem.h
Modules/main.c
Objects/obmalloc.c
Python/coreconfig.c
Python/import.c
Python/pathconfig.c
Python/pylifecycle.c
Python/pystate.c
Python/sysmodule.c

index a731e30e6af7d2d530a55f92bf932d7c11a8d48d..4a41b77734ac41aee1c303640c1bfa7a6f487973 100644 (file)
@@ -4,6 +4,10 @@
 extern "C" {
 #endif
 
+#ifndef Py_BUILD_CORE
+#  error "Py_BUILD_CORE must be defined to include this header"
+#endif
+
 #include "objimpl.h"
 #include "pymem.h"
 
@@ -145,6 +149,14 @@ PyAPI_FUNC(void) _PyGC_Initialize(struct _gc_runtime_state *);
 
 #define _PyGC_generation0 _PyRuntime.gc.generation0
 
+
+/* 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);
+
 #ifdef __cplusplus
 }
 #endif
index 19f0c8a2d9bfbdcf1b575a658eef1467b4442bfa..23457adb5a45e9b2a156f2614b3867cb565222f6 100644 (file)
@@ -198,16 +198,6 @@ PyAPI_FUNC(void) PyMem_SetAllocator(PyMemAllocatorDomain domain,
 PyAPI_FUNC(void) PyMem_SetupDebugHooks(void);
 #endif   /* Py_LIMITED_API */
 
-#ifdef Py_BUILD_CORE
-/* 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
-
-
 /* bpo-35053: expose _Py_tracemalloc_config for performance:
    _Py_NewReference() needs an efficient check to test if tracemalloc is
    tracing.
index 455178af8bab12d88c174e7a1f76a264179e40ef..6a8aa05fc370eaca6e8d63aa419573429991ea92 100644 (file)
@@ -2,6 +2,7 @@
 
 #include "Python.h"
 #include "osdefs.h"
+#include "internal/mem.h"
 #include "internal/pygetopt.h"
 #include "internal/pystate.h"
 
index fbc947806908fe594869263e93b103937b7c9678..88ded83a29e41aeba00419324a73cf5c765cc85e 100644 (file)
@@ -1,4 +1,5 @@
 #include "Python.h"
+#include "internal/mem.h"
 
 #include <stdbool.h>
 
index a82175e4fd26a9e9bf70d70374ee3c5ff28c9c88..81086f42d679c687ae5228bada643f60d0f71ab9 100644 (file)
@@ -1,4 +1,5 @@
 #include "Python.h"
+#include "internal/mem.h"
 #include "internal/pystate.h"
 #include <locale.h>
 #ifdef HAVE_LANGINFO_H
index e761f65c66ba7f0ccd358230d0a7e924d822f4b9..338cd302dcc0ec770cd9882690ef4aacaac33230 100644 (file)
@@ -5,6 +5,7 @@
 #include "Python-ast.h"
 #undef Yield /* undefine macro conflicting with winbase.h */
 #include "internal/hash.h"
+#include "internal/mem.h"
 #include "internal/pystate.h"
 #include "errcode.h"
 #include "marshal.h"
index 4e0830f4cf9afb6b703f6cf1b76e728e5028068e..efccb8d6bb8523982452ef58fbe17555c10176d7 100644 (file)
@@ -2,6 +2,7 @@
 
 #include "Python.h"
 #include "osdefs.h"
+#include "internal/mem.h"
 #include "internal/pystate.h"
 #include <wchar.h>
 
index f1579c781df771a9ca62468f33c1061eb57c597d..78691a54f37f22e21e76f4ec43a565716158023e 100644 (file)
@@ -6,6 +6,7 @@
 #undef Yield /* undefine macro conflicting with winbase.h */
 #include "internal/context.h"
 #include "internal/hamt.h"
+#include "internal/mem.h"
 #include "internal/pystate.h"
 #include "grammar.h"
 #include "node.h"
index d04981121c1ca47ab9c7d091f9038bd014425478..98e954d9d91db6995cebb7d5ceae44cbd6899dc2 100644 (file)
@@ -2,6 +2,7 @@
 /* Thread and interpreter state structures and their interfaces */
 
 #include "Python.h"
+#include "internal/mem.h"
 #include "internal/pystate.h"
 
 #define _PyThreadState_SET(value) \
index 9579eae4ff5f4d28b11919789a22a4f600668446..71414c959789e5fa2ebaac86193d9804167824e5 100644 (file)
@@ -15,6 +15,7 @@ Data members:
 */
 
 #include "Python.h"
+#include "internal/mem.h"
 #include "internal/pystate.h"
 #include "code.h"
 #include "frameobject.h"