Commit 47f7dfcc authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

ntdll: Remove entries from the free list in HEAP_FindFreeBlock.

parent 1bb92df7
......@@ -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 )
{
struct entry *entry = find_free_list( heap, data_size + sizeof(ARENA_INUSE), FALSE );
SIZE_T total_size, arena_size;
ARENA_FREE *pArena;
SUBHEAP *subheap;
struct list *ptr;
SIZE_T total_size;
/* Find a suitable free list, and in it find a block large enough */
ptr = &entry->entry;
while ((ptr = list_next( &heap->freeList[0].arena.entry, ptr )))
{
ARENA_FREE *pArena = LIST_ENTRY( ptr, ARENA_FREE, entry );
SIZE_T arena_size = (pArena->size & ARENA_SIZE_MASK) +
sizeof(ARENA_FREE) - sizeof(ARENA_INUSE);
pArena = LIST_ENTRY( ptr, ARENA_FREE, entry );
arena_size = (pArena->size & ARENA_SIZE_MASK) + sizeof(ARENA_FREE) - sizeof(ARENA_INUSE);
if (arena_size >= data_size)
{
subheap = find_subheap( heap, (struct block *)pArena, FALSE );
if (!HEAP_Commit( subheap, (ARENA_INUSE *)pArena, data_size )) return NULL;
*ppSubHeap = subheap;
list_remove( &pArena->entry );
return pArena;
}
}
......@@ -1120,7 +1121,9 @@ static ARENA_FREE *HEAP_FindFreeBlock( HEAP *heap, SIZE_T data_size, SUBHEAP **p
subheap, subheap->size, heap );
*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;
/* Remove the arena from the free list */
list_remove( &entry->entry );
/* Build the in-use arena */
block = (struct block *)entry;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment