[ros-diffs] [ion] 22576: - Fix implementation of RtlSetUserValueHeap and RtlGetUserInfoHeap to write their flags to the subheap and not the actual main heap structure (since those flags are valid for each allocation). - Make heap allocations 8-byte aligned again.

ion at svn.reactos.org ion at svn.reactos.org
Sat Jun 24 19:05:06 CEST 2006


Author: ion
Date: Sat Jun 24 21:05:05 2006
New Revision: 22576

URL: http://svn.reactos.org/svn/reactos?rev=22576&view=rev
Log:
- Fix implementation of RtlSetUserValueHeap and RtlGetUserInfoHeap to write their flags to the subheap and not the actual main heap structure (since those flags are valid for each allocation).
- Make heap allocations 8-byte aligned again.

Modified:
    trunk/reactos/lib/rtl/heap.c

Modified: trunk/reactos/lib/rtl/heap.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/heap.c?rev=22576&r1=22575&r2=22576&view=diff
==============================================================================
--- trunk/reactos/lib/rtl/heap.c (original)
+++ trunk/reactos/lib/rtl/heap.c Sat Jun 24 21:05:05 2006
@@ -87,6 +87,8 @@
    struct tagSUBHEAP  *next;       /* Next sub-heap */
    struct tagHEAP     *heap;       /* Main heap structure */
    ULONG               magic;      /* Magic number */
+   ULONG UserFlags;
+   PVOID UserValue;
 }
 SUBHEAP, *PSUBHEAP;
 
@@ -100,7 +102,6 @@
    RTL_CRITICAL_SECTION critSection;   /* Critical section for serialization */
    ULONG            flags;         /* Heap flags */
    ULONG            magic;         /* Magic number */
-   PVOID UserValue;
    PRTL_HEAP_COMMIT_ROUTINE commitRoutine;
 }
 HEAP, *PHEAP;
@@ -1250,6 +1251,9 @@
    pInUse->threadId  = (ULONG)NtCurrentTeb()->Cid.UniqueThread;
    pInUse->magic     = ARENA_INUSE_MAGIC;
 
+   /* Save user flags */
+   subheap->UserFlags = flags & HEAP_SETTABLE_USER_FLAGS;
+
    /* Shrink the block */
 
    HEAP_ShrinkBlock( subheap, pInUse, size );
@@ -1262,7 +1266,7 @@
    if (!(flags & HEAP_NO_SERIALIZE))
       RtlLeaveHeapLock( &heapPtr->critSection );
 
-   DPRINT("(%p,%08lx,%08lx): returning %p\n",
+   DPRINT1("(%p,%08lx,%08lx): returning %p\n",
          heap, flags, size, (PVOID)(pInUse + 1) );
    return (PVOID)(pInUse + 1);
 }
@@ -1855,9 +1859,15 @@
                     IN PVOID UserValue)
 {
     HEAP *heapPtr = HEAP_GetPtr(HeapHandle);
+    ARENA_INUSE *pInUse;
+    SUBHEAP *subheap;
+
+    /* Get the subheap */
+    pInUse  = (ARENA_INUSE *)BaseAddress - 1;
+    subheap = HEAP_FindSubHeap( heapPtr, pInUse );
 
     /* Hack */
-    heapPtr->UserValue = UserValue;
+    subheap->UserValue = UserValue;
     return TRUE;
 }
 
@@ -1873,10 +1883,16 @@
                    OUT PULONG UserFlags)
 {
     HEAP *heapPtr = HEAP_GetPtr(HeapHandle);
+    ARENA_INUSE *pInUse;
+    SUBHEAP *subheap;
+
+    /* Get the subheap */
+    pInUse  = (ARENA_INUSE *)BaseAddress - 1;
+    subheap = HEAP_FindSubHeap( heapPtr, pInUse );
 
     /* Hack */
-    if (UserValue) *UserValue = heapPtr->UserValue;
-    if (UserFlags) *UserFlags = heapPtr->flags & HEAP_SETTABLE_USER_FLAGS;
+    if (UserValue) *UserValue = subheap->UserValue;
+    if (UserFlags) *UserFlags = subheap->UserFlags;
     return TRUE;
 }
 




More information about the Ros-diffs mailing list