mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-15 07:28:47 +00:00
ntdll: Fail to allocate large blocks if heap isn't growable.
This tweaks the test sizes so that it passes on Wine too. The created heap should be large enough to hold the requested alloc size, but the allocation still fails. Windows seems to have a specific lower threshold for large blocks with non growable heaps, but it's probably not very useful to match it. Signed-off-by: Rémi Bernon <rbernon@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
69c75b2b1d
commit
3728b2b7d2
|
@ -456,7 +456,7 @@ static void test_HeapCreate(void)
|
|||
ok( ret, "HeapDestroy failed, error %lu\n", GetLastError() );
|
||||
|
||||
|
||||
heap = HeapCreate( 0, 2 * alloc_size, 5 * alloc_size );
|
||||
heap = HeapCreate( 0, 8 * alloc_size, 8 * alloc_size );
|
||||
ok( !!heap, "HeapCreate failed, error %lu\n", GetLastError() );
|
||||
ok( !((ULONG_PTR)heap & 0xffff), "wrong heap alignment\n" );
|
||||
|
||||
|
@ -470,10 +470,8 @@ static void test_HeapCreate(void)
|
|||
/* cannot allocate large blocks from fixed size heap */
|
||||
|
||||
SetLastError( 0xdeadbeef );
|
||||
ptr1 = HeapAlloc( heap, 0, 3 * alloc_size );
|
||||
todo_wine
|
||||
ptr1 = HeapAlloc( heap, 0, 4 * alloc_size );
|
||||
ok( !ptr1, "HeapAlloc succeeded\n" );
|
||||
todo_wine
|
||||
ok( GetLastError() == ERROR_NOT_ENOUGH_MEMORY, "got error %lu\n", GetLastError() );
|
||||
ret = HeapFree( heap, 0, ptr1 );
|
||||
ok( ret, "HeapFree failed, error %lu\n", GetLastError() );
|
||||
|
|
|
@ -841,6 +841,7 @@ static void *allocate_large_block( HEAP *heap, DWORD flags, SIZE_T size )
|
|||
SIZE_T block_size = sizeof(*arena) + ROUND_SIZE(size) + HEAP_TAIL_EXTRA_SIZE(flags);
|
||||
LPVOID address = NULL;
|
||||
|
||||
if (!(flags & HEAP_GROWABLE)) return NULL;
|
||||
if (block_size < size) return NULL; /* overflow */
|
||||
if (NtAllocateVirtualMemory( NtCurrentProcess(), &address, 0, &block_size,
|
||||
MEM_COMMIT, get_protection_type( flags )))
|
||||
|
@ -1561,7 +1562,7 @@ static NTSTATUS heap_allocate( HEAP *heap, ULONG flags, SIZE_T size, void **ret
|
|||
if (rounded_size < size) return STATUS_NO_MEMORY; /* overflow */
|
||||
if (rounded_size < HEAP_MIN_DATA_SIZE) rounded_size = HEAP_MIN_DATA_SIZE;
|
||||
|
||||
if (rounded_size >= HEAP_MIN_LARGE_BLOCK_SIZE && (flags & HEAP_GROWABLE))
|
||||
if (rounded_size >= HEAP_MIN_LARGE_BLOCK_SIZE)
|
||||
{
|
||||
if (!(*ret = allocate_large_block( heap, flags, size ))) return STATUS_NO_MEMORY;
|
||||
return STATUS_SUCCESS;
|
||||
|
@ -1685,7 +1686,7 @@ static NTSTATUS heap_reallocate( HEAP *heap, ULONG flags, void *ptr, SIZE_T size
|
|||
{
|
||||
struct block *next;
|
||||
|
||||
if (rounded_size >= HEAP_MIN_LARGE_BLOCK_SIZE && (flags & HEAP_GROWABLE))
|
||||
if (rounded_size >= HEAP_MIN_LARGE_BLOCK_SIZE)
|
||||
{
|
||||
if (flags & HEAP_REALLOC_IN_PLACE_ONLY) return STATUS_NO_MEMORY;
|
||||
if (!(*ret = allocate_large_block( heap, flags, size ))) return STATUS_NO_MEMORY;
|
||||
|
|
Loading…
Reference in a new issue