Rémi Bernon : ntdll: Merge HEAP_InsertFreeBlock with create_free_block.

Alexandre Julliard julliard at winehq.org
Tue May 24 15:54:59 CDT 2022


Module: wine
Branch: master
Commit: 66036effdf8f017a0e0f2bea0f830f6054691ee7
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=66036effdf8f017a0e0f2bea0f830f6054691ee7

Author: Rémi Bernon <rbernon at codeweavers.com>
Date:   Wed May  4 20:50:48 2022 +0200

ntdll: Merge HEAP_InsertFreeBlock with create_free_block.

Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>

---

 dlls/ntdll/heap.c | 28 ++++------------------------
 1 file changed, 4 insertions(+), 24 deletions(-)

diff --git a/dlls/ntdll/heap.c b/dlls/ntdll/heap.c
index 767a010d93e..5fe23a3502e 100644
--- a/dlls/ntdll/heap.c
+++ b/dlls/ntdll/heap.c
@@ -595,28 +595,6 @@ static HEAP *HEAP_GetPtr(
 }
 
 
-/***********************************************************************
- *           HEAP_InsertFreeBlock
- *
- * Insert a free block into the free list.
- */
-static inline void HEAP_InsertFreeBlock( HEAP *heap, ARENA_FREE *pArena, BOOL last )
-{
-    SIZE_T block_size = (pArena->size & ARENA_SIZE_MASK) + sizeof(*pArena);
-    struct entry *list = find_free_list( heap, block_size, last );
-    if (last)
-    {
-        /* insert at end of free list, i.e. before the next free list entry */
-        list_add_before( &list->entry, &pArena->entry );
-    }
-    else
-    {
-        /* insert at head of free list */
-        list_add_after( &list->entry, &pArena->entry );
-    }
-}
-
-
 static SUBHEAP *find_subheap( const HEAP *heap, const struct block *block, BOOL heap_walk )
 {
     SUBHEAP *subheap;
@@ -692,7 +670,7 @@ static inline BOOL HEAP_Decommit( SUBHEAP *subheap, void *ptr )
 static void create_free_block( SUBHEAP *subheap, struct block *block, SIZE_T block_size )
 {
     const char *end = (char *)block + block_size, *commit_end = subheap_commit_end( subheap );
-    struct entry *entry = (struct entry *)block;
+    struct entry *entry = (struct entry *)block, *list;
     HEAP *heap = subheap->heap;
     DWORD flags = heap->flags;
     struct block *next;
@@ -724,7 +702,9 @@ static void create_free_block( SUBHEAP *subheap, struct block *block, SIZE_T blo
         *((struct block **)next - 1) = block;
     }
 
-    HEAP_InsertFreeBlock( heap, entry, !next );
+    list = find_free_list( heap, block_get_size( block ), !next );
+    if (!next) list_add_before( &list->entry, &entry->entry );
+    else list_add_after( &list->entry, &entry->entry );
 }
 
 




More information about the wine-cvs mailing list