From cd83fa8c3e8509418215c55b89e52160dc38e50d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Thu, 27 Jun 2013 12:23:29 +0200 Subject: Issue #13483: Use VirtualAlloc in obmalloc on Windows. --- Misc/NEWS | 2 ++ Objects/obmalloc.c | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS index bc825dc..dacbf1c 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,8 @@ What's New in Python 3.4.0 Alpha 1? Core and Builtins ----------------- +- Issue #13483: Use VirtualAlloc in obmalloc on Windows. + - Issue #18184: PyUnicode_FromFormat() and PyUnicode_FromFormatV() now raise OverflowError when an argument of %c format is out of range. 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 +#endif + #ifdef WITH_VALGRIND #include @@ -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); -- cgit v0.12