HEAP_Commit/Decommit were assuming a page size of 4KB

unconditionally.
This commit is contained in:
Ulrich Weigand 1999-09-03 16:45:04 +00:00 committed by Alexandre Julliard
parent 4e877163cf
commit 73bd8d2b1c
1 changed files with 4 additions and 2 deletions

View File

@ -263,7 +263,8 @@ static SUBHEAP *HEAP_FindSubHeap(
static BOOL HEAP_Commit( SUBHEAP *subheap, void *ptr ) static BOOL HEAP_Commit( SUBHEAP *subheap, void *ptr )
{ {
DWORD size = (DWORD)((char *)ptr - (char *)subheap); 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->size) size = subheap->size;
if (size <= subheap->commitSize) return TRUE; if (size <= subheap->commitSize) return TRUE;
if (!VirtualAlloc( (char *)subheap + subheap->commitSize, 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 ) static BOOL HEAP_Decommit( SUBHEAP *subheap, void *ptr )
{ {
DWORD size = (DWORD)((char *)ptr - (char *)subheap); 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 (size >= subheap->commitSize) return TRUE;
if (!VirtualFree( (char *)subheap + size, if (!VirtualFree( (char *)subheap + size,
subheap->commitSize - size, MEM_DECOMMIT )) subheap->commitSize - size, MEM_DECOMMIT ))