Rémi Bernon : ntdll: Use a block member in the free list entry struct.
Alexandre Julliard
julliard at winehq.org
Fri May 27 16:35:28 CDT 2022
Module: wine
Branch: master
Commit: 7964d641225dd322557db16b5c89ed6e5734ed8e
URL: https://source.winehq.org/git/wine.git/?a=commit;h=7964d641225dd322557db16b5c89ed6e5734ed8e
Author: Rémi Bernon <rbernon at codeweavers.com>
Date: Wed May 4 00:06:27 2022 +0200
ntdll: Use a block member in the free list entry struct.
And use ARENA_FLAG_FREE|ARENA_FLAG_PREV_FREE flag combination to mark
and ignore free list links.
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
dlls/ntdll/heap.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/dlls/ntdll/heap.c b/dlls/ntdll/heap.c
index 0f75ef1fe81..411bb26aa3d 100644
--- a/dlls/ntdll/heap.c
+++ b/dlls/ntdll/heap.c
@@ -94,9 +94,8 @@ C_ASSERT( sizeof(struct block) == 8 );
typedef struct entry
{
- DWORD size; /* Block size; must be the first field */
- DWORD magic; /* Magic number */
- struct list entry; /* Entry in free list */
+ struct block block;
+ struct list entry;
} ARENA_FREE;
typedef struct
@@ -972,8 +971,8 @@ static SUBHEAP *HEAP_CreateSubHeap( HEAP *heap, LPVOID address, DWORD flags,
list_init( &heap->freeList[0].arena.entry );
for (i = 0, pEntry = heap->freeList; i < HEAP_NB_FREE_LISTS; i++, pEntry++)
{
- pEntry->arena.size = BLOCK_FLAG_FREE_LINK;
- pEntry->arena.magic = ARENA_FREE_MAGIC;
+ block_set_size( &pEntry->arena.block, BLOCK_FLAG_FREE_LINK, 0 );
+ block_set_type( &pEntry->arena.block, ARENA_FREE_MAGIC );
if (i) list_add_after( &pEntry[-1].arena.entry, &pEntry->arena.entry );
}
@@ -1080,7 +1079,7 @@ static BOOL is_valid_free_block( const HEAP *heap, const struct block *block )
if ((subheap = find_subheap( heap, block, FALSE ))) return TRUE;
if (block_get_flags( block ) != BLOCK_FLAG_FREE_LINK) return FALSE;
- for (i = 0; i < HEAP_NB_FREE_LISTS; i++) if (block == (struct block *)&heap->freeList[i].arena) return TRUE;
+ for (i = 0; i < HEAP_NB_FREE_LISTS; i++) if (block == &heap->freeList[i].arena.block) return TRUE;
return FALSE;
}
More information about the wine-cvs
mailing list