From 73bd8d2b1c5069db987801d6246e7aabb4aab37c Mon Sep 17 00:00:00 2001 From: Ulrich Weigand Date: Fri, 3 Sep 1999 16:45:04 +0000 Subject: [PATCH] HEAP_Commit/Decommit were assuming a page size of 4KB unconditionally. --- memory/heap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/memory/heap.c b/memory/heap.c index c7e4e6f2bf3..dd74be1c810 100644 --- a/memory/heap.c +++ b/memory/heap.c @@ -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 ))