Author: fireball Date: Fri Oct 8 09:47:48 2010 New Revision: 49048
URL: http://svn.reactos.org/svn/reactos?rev=49048&view=rev Log: [HEAP] - Roel Messiant: Remove old-style Peb->ProcessHeaps assignment from RTL, it's already done by MM. - Roel Messiant: Fix a typo (missing else) between two if branches, which fixes commit routine support. - Properly save requested size if 0 was given (1 should be allocated, but 0 saved as a requested amount). Fixes winetests. - Remove unnecessary dprints.
Modified: trunk/reactos/lib/rtl/heap_rewrite.c
Modified: trunk/reactos/lib/rtl/heap_rewrite.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/heap_rewrite.c?rev=... ============================================================================== --- trunk/reactos/lib/rtl/heap_rewrite.c [iso-8859-1] (original) +++ trunk/reactos/lib/rtl/heap_rewrite.c [iso-8859-1] Fri Oct 8 09:47:48 2010 @@ -24,7 +24,6 @@ // Various defines, to be moved to a separate header file #define HEAP_FREELISTS 128 #define HEAP_SEGMENTS 64 -#define HEAP_MAX_PROCESS_HEAPS 16
#define HEAP_ENTRY_SIZE ((ULONG)sizeof(HEAP_ENTRY)) #define HEAP_ENTRY_SHIFT 3 @@ -271,7 +270,6 @@ PRTL_HEAP_PARAMETERS Parameters) { return NULL; };
HEAP_LOCK RtlpProcessHeapsListLock; -PHEAP RtlpProcessHeaps[HEAP_MAX_PROCESS_HEAPS]; /* Usermode only */
/* Heap entry flags */ #define HEAP_ENTRY_BUSY 0x01 @@ -1574,9 +1572,6 @@ if (NtGlobalFlags & FLG_HEAP_ENABLE_TAIL_CHECK) Flags |= HEAP_TAIL_CHECKING_ENABLED;
- if (Flags & HEAP_TAIL_CHECKING_ENABLED) - DPRINT1("TailChecking!\n"); - if (RtlpGetMode() == UserMode) { /* Also check these flags if in usermode */ @@ -1704,6 +1699,7 @@ /* Zero the initial page ourselves */ RtlZeroMemory(CommittedAddress, PAGE_SIZE); } + else { /* Commit routine is absent, so query how much memory caller reserved */ Status = ZwQueryVirtualMemory(NtCurrentProcess(), @@ -1872,6 +1868,7 @@ // FIXME: What about lookasides? }
+ DPRINT("Heap %p, flags 0x%08x\n", Heap, Heap->Flags); return Heap; }
@@ -2286,8 +2283,7 @@ DPRINT1("HEAP: RtlAllocateHeap is called with unsupported flags %x, ignoring\n", Flags); }
- if (Flags & HEAP_TAIL_CHECKING_ENABLED) - DPRINT1("TailChecking, Heap %p\n!", Heap); + //DPRINT("RtlAllocateHeap(%p %x %x)\n", Heap, Flags, Size);
/* Calculate allocation size and index */ if (Size) @@ -2689,8 +2685,11 @@ }
/* Calculate allocation size and index */ - if (!Size) Size = 1; - AllocationSize = (Size + Heap->AlignRound) & Heap->AlignMask; + if (Size) + AllocationSize = Size; + else + AllocationSize = 1; + AllocationSize = (AllocationSize + Heap->AlignRound) & Heap->AlignMask;
/* Add up extra stuff, if it is present anywhere */ if (((((PHEAP_ENTRY)Ptr)-1)->Flags & HEAP_ENTRY_EXTRA_PRESENT) || @@ -3225,8 +3224,6 @@
/* Initialize heap-related fields of PEB */ Peb->NumberOfHeaps = 0; - Peb->MaximumNumberOfHeaps = HEAP_MAX_PROCESS_HEAPS; - Peb->ProcessHeaps = (PVOID)RtlpProcessHeaps;
/* Initialize the process heaps list protecting lock */ RtlInitializeHeapLock(&RtlpProcessHeapsListLock);