diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2013-06-27 10:23:29 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2013-06-27 10:23:29 (GMT) |
commit | cd83fa8c3e8509418215c55b89e52160dc38e50d (patch) | |
tree | b88feead5894d1cc57eba2d3ff4b6ce5d773386f /Objects/obmalloc.c | |
parent | fe3ae3cdc78e92872930f288d5c52cafb20b052a (diff) | |
download | cpython-cd83fa8c3e8509418215c55b89e52160dc38e50d.zip cpython-cd83fa8c3e8509418215c55b89e52160dc38e50d.tar.gz cpython-cd83fa8c3e8509418215c55b89e52160dc38e50d.tar.bz2 |
Issue #13483: Use VirtualAlloc in obmalloc on Windows.
Diffstat (limited to 'Objects/obmalloc.c')
-rw-r--r-- | Objects/obmalloc.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/Objects/obmalloc.c b/Objects/obmalloc.c index 3028f22..3fac6d4 100644 --- a/Objects/obmalloc.c +++ b/Objects/obmalloc.c @@ -9,6 +9,10 @@ #endif #endif +#ifdef MS_WINDOWS +#include <windows.h> +#endif + #ifdef WITH_VALGRIND #include <valgrind/valgrind.h> @@ -598,7 +602,11 @@ new_arena(void) arenaobj = unused_arena_objects; unused_arena_objects = arenaobj->nextarena; assert(arenaobj->address == 0); -#ifdef ARENAS_USE_MMAP +#ifdef MS_WINDOWS + address = (void*)VirtualAlloc(NULL, ARENA_SIZE, + MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); + err = (address == NULL); +#elif defined(ARENAS_USE_MMAP) address = mmap(NULL, ARENA_SIZE, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); err = (address == MAP_FAILED); @@ -1093,7 +1101,9 @@ PyObject_Free(void *p) unused_arena_objects = ao; /* Free the entire arena. */ -#ifdef ARENAS_USE_MMAP +#ifdef MS_WINDOWS + VirtualFree((void *)ao->address, 0, MEM_RELEASE); +#elif defined(ARENAS_USE_MMAP) munmap((void *)ao->address, ARENA_SIZE); #else free((void *)ao->address); |