Rémi Bernon : ntdll: Use block helpers in find_free_block.
Alexandre Julliard
julliard at winehq.org
Mon May 23 15:51:52 CDT 2022
Module: wine
Branch: master
Commit: 43ac858e2748d72c28021b9378cff3af36ae7d80
URL: https://source.winehq.org/git/wine.git/?a=commit;h=43ac858e2748d72c28021b9378cff3af36ae7d80
Author: Rémi Bernon <rbernon at codeweavers.com>
Date: Tue May 3 19:55:36 2022 +0200
ntdll: Use block helpers in find_free_block.
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
dlls/ntdll/heap.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/dlls/ntdll/heap.c b/dlls/ntdll/heap.c
index 658a8bc1ab0..302e6cc75ee 100644
--- a/dlls/ntdll/heap.c
+++ b/dlls/ntdll/heap.c
@@ -1061,8 +1061,9 @@ static SUBHEAP *HEAP_CreateSubHeap( HEAP *heap, LPVOID address, DWORD flags,
static struct block *find_free_block( HEAP *heap, SIZE_T data_size, SUBHEAP **subheap )
{
struct list *ptr = &find_free_list( heap, data_size + sizeof(ARENA_INUSE), FALSE )->entry;
- SIZE_T total_size, arena_size;
struct entry *entry;
+ struct block *block;
+ SIZE_T total_size;
/* Find a suitable free list, and in it find a block large enough */
@@ -1070,13 +1071,13 @@ static struct block *find_free_block( HEAP *heap, SIZE_T data_size, SUBHEAP **su
{
entry = LIST_ENTRY( ptr, struct entry, entry );
if (entry->size == (0 | ARENA_FLAG_FREE)) continue;
- arena_size = (entry->size & ARENA_SIZE_MASK) + sizeof(ARENA_FREE) - sizeof(ARENA_INUSE);
- if (arena_size >= data_size)
+ block = (struct block *)entry;
+ if (block_get_size( block ) - sizeof(*block) >= data_size)
{
- *subheap = find_subheap( heap, (struct block *)entry, FALSE );
- if (!HEAP_Commit( *subheap, (struct block *)entry, data_size )) return NULL;
+ *subheap = find_subheap( heap, block, FALSE );
+ if (!HEAP_Commit( *subheap, block, data_size )) return NULL;
list_remove( &entry->entry );
- return (struct block *)entry;
+ return block;
}
}
More information about the wine-cvs
mailing list