[PATCH v2 7/8] ntdll: Round free block size to block size alignment.

Rémi Bernon wine at gitlab.winehq.org
Thu Jun 2 01:24:44 CDT 2022


From: Rémi Bernon <rbernon at codeweavers.com>

Block sizes are now always rounded to ALIGNMENT multiple, except for
the last free block in a region. This makes it consistent and will let
us use a more compact block layout.

Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
 dlls/ntdll/heap.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/dlls/ntdll/heap.c b/dlls/ntdll/heap.c
index 0a6228217ff..3f14de39a1d 100644
--- a/dlls/ntdll/heap.c
+++ b/dlls/ntdll/heap.c
@@ -892,6 +892,7 @@ static SUBHEAP *HEAP_CreateSubHeap( HEAP *heap, LPVOID address, DWORD flags,
                                     SIZE_T commitSize, SIZE_T totalSize )
 {
     struct entry *pEntry;
+    SIZE_T block_size;
     SUBHEAP *subheap;
     unsigned int i;
 
@@ -991,9 +992,9 @@ static SUBHEAP *HEAP_CreateSubHeap( HEAP *heap, LPVOID address, DWORD flags,
         }
     }
 
-    /* Create the first free block */
-
-    create_free_block( subheap, first_block( subheap ), subheap_size( subheap ) - subheap_overhead( subheap ) );
+    block_size = subheap_size( subheap ) - subheap_overhead( subheap );
+    block_size &= ~(ALIGNMENT - 1);
+    create_free_block( subheap, first_block( subheap ), block_size );
 
     return subheap;
 }
-- 
GitLab


https://gitlab.winehq.org/wine/wine/-/merge_requests/165



More information about the wine-devel mailing list