Commit 73bd8d2b authored by Ulrich Weigand's avatar Ulrich Weigand Committed by Alexandre Julliard

HEAP_Commit/Decommit were assuming a page size of 4KB

unconditionally.
parent 4e877163
......@@ -263,7 +263,8 @@ static SUBHEAP *HEAP_FindSubHeap(
static BOOL HEAP_Commit( SUBHEAP *subheap, void *ptr )
{
DWORD size = (DWORD)((char *)ptr - (char *)subheap);
size = (size + 0xfff) & 0xfffff000; /* Align size on a page boundary */
DWORD pageMask = VIRTUAL_GetPageSize() - 1;
size = (size + pageMask) & ~pageMask; /* Align size on a page boundary */
if (size > subheap->size) size = subheap->size;
if (size <= subheap->commitSize) return TRUE;
if (!VirtualAlloc( (char *)subheap + subheap->commitSize,
......@@ -289,7 +290,8 @@ static BOOL HEAP_Commit( SUBHEAP *subheap, void *ptr )
static BOOL HEAP_Decommit( SUBHEAP *subheap, void *ptr )
{
DWORD size = (DWORD)((char *)ptr - (char *)subheap);
size = (size + 0xfff) & 0xfffff000; /* Align size on a page boundary */
DWORD pageMask = VIRTUAL_GetPageSize() - 1;
size = (size + pageMask) & ~pageMask; /* Align size on a page boundary */
if (size >= subheap->commitSize) return TRUE;
if (!VirtualFree( (char *)subheap + size,
subheap->commitSize - size, MEM_DECOMMIT ))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment