ntdll: Remove entries from the free list in HEAP_FindFreeBlock.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
1bb92df7c4
commit
47f7dfcc2c
|
@ -1067,23 +1067,24 @@ static SUBHEAP *HEAP_CreateSubHeap( HEAP *heap, LPVOID address, DWORD flags,
|
||||||
static ARENA_FREE *HEAP_FindFreeBlock( HEAP *heap, SIZE_T data_size, SUBHEAP **ppSubHeap )
|
static ARENA_FREE *HEAP_FindFreeBlock( HEAP *heap, SIZE_T data_size, SUBHEAP **ppSubHeap )
|
||||||
{
|
{
|
||||||
struct entry *entry = find_free_list( heap, data_size + sizeof(ARENA_INUSE), FALSE );
|
struct entry *entry = find_free_list( heap, data_size + sizeof(ARENA_INUSE), FALSE );
|
||||||
|
SIZE_T total_size, arena_size;
|
||||||
|
ARENA_FREE *pArena;
|
||||||
SUBHEAP *subheap;
|
SUBHEAP *subheap;
|
||||||
struct list *ptr;
|
struct list *ptr;
|
||||||
SIZE_T total_size;
|
|
||||||
|
|
||||||
/* Find a suitable free list, and in it find a block large enough */
|
/* Find a suitable free list, and in it find a block large enough */
|
||||||
|
|
||||||
ptr = &entry->entry;
|
ptr = &entry->entry;
|
||||||
while ((ptr = list_next( &heap->freeList[0].arena.entry, ptr )))
|
while ((ptr = list_next( &heap->freeList[0].arena.entry, ptr )))
|
||||||
{
|
{
|
||||||
ARENA_FREE *pArena = LIST_ENTRY( ptr, ARENA_FREE, entry );
|
pArena = LIST_ENTRY( ptr, ARENA_FREE, entry );
|
||||||
SIZE_T arena_size = (pArena->size & ARENA_SIZE_MASK) +
|
arena_size = (pArena->size & ARENA_SIZE_MASK) + sizeof(ARENA_FREE) - sizeof(ARENA_INUSE);
|
||||||
sizeof(ARENA_FREE) - sizeof(ARENA_INUSE);
|
|
||||||
if (arena_size >= data_size)
|
if (arena_size >= data_size)
|
||||||
{
|
{
|
||||||
subheap = find_subheap( heap, (struct block *)pArena, FALSE );
|
subheap = find_subheap( heap, (struct block *)pArena, FALSE );
|
||||||
if (!HEAP_Commit( subheap, (ARENA_INUSE *)pArena, data_size )) return NULL;
|
if (!HEAP_Commit( subheap, (ARENA_INUSE *)pArena, data_size )) return NULL;
|
||||||
*ppSubHeap = subheap;
|
*ppSubHeap = subheap;
|
||||||
|
list_remove( &pArena->entry );
|
||||||
return pArena;
|
return pArena;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1120,7 +1121,9 @@ static ARENA_FREE *HEAP_FindFreeBlock( HEAP *heap, SIZE_T data_size, SUBHEAP **p
|
||||||
subheap, subheap->size, heap );
|
subheap, subheap->size, heap );
|
||||||
|
|
||||||
*ppSubHeap = subheap;
|
*ppSubHeap = subheap;
|
||||||
return (ARENA_FREE *)((char *)subheap->base + subheap->headerSize);
|
pArena = (ARENA_FREE *)((char *)subheap->base + subheap->headerSize);
|
||||||
|
list_remove( &pArena->entry );
|
||||||
|
return pArena;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1553,10 +1556,6 @@ static NTSTATUS heap_allocate( HEAP *heap, ULONG flags, SIZE_T size, void **ret
|
||||||
|
|
||||||
if (!(entry = HEAP_FindFreeBlock( heap, data_size, &subheap ))) return STATUS_NO_MEMORY;
|
if (!(entry = HEAP_FindFreeBlock( heap, data_size, &subheap ))) return STATUS_NO_MEMORY;
|
||||||
|
|
||||||
/* Remove the arena from the free list */
|
|
||||||
|
|
||||||
list_remove( &entry->entry );
|
|
||||||
|
|
||||||
/* Build the in-use arena */
|
/* Build the in-use arena */
|
||||||
|
|
||||||
block = (struct block *)entry;
|
block = (struct block *)entry;
|
||||||
|
|
Loading…
Reference in New Issue