Rémi Bernon (@rbernon) commented about dlls/kernel32/tests/heap.c:
+ if (flags & HEAP_TAIL_CHECKING_ENABLED) + ok( p[39] == 0xab, "got %#x.\n", p[39] ); + for (i = 0; i < count - 1; ++i) + ok( ((unsigned int *)p)[10 + i] == 0xbaadf00d, "got %#x, i %Iu.\n", ((unsigned int *)p)[10 + i], i ); + } + else + { + ok( p[39] == 0xba, "got %#x.\n", p[39] ); + for (i = 0; i < count - 1; ++i) + ok( ((unsigned int *)p)[10 + i] == 0xbaadf00d, "got %#x, i %Iu.\n", ((unsigned int *)p)[10 + i], i ); + } + winetest_pop_context(); + + ret = pHeapFree( GetProcessHeap(), 0, p ); + ok( ret, "failed.\n" ); + }
if (flags & HEAP_FREE_CHECKING_ENABLED)
{
UINT *p32, tmp = 0;
size = 4 + 3;
p = pHeapAlloc( GetProcessHeap(), 0, size );
ok( !!p, "HeapAlloc failed\n" );
p32 = (UINT *)p;
ok( p32[0] == 0xbaadf00d, "got %#x\n", p32[0] );
memcpy( &tmp, p + size - 3, 3 );
ok( tmp != 0xadf00d, "got %#x\n", tmp );
memset( p, 0xcc, size );
size += 2 * 4;
p = pHeapReAlloc( GetProcessHeap(), 0, p, size );
ok( !!p, "HeapReAlloc failed\n" );
p32 = (UINT *)p;
ok( p32[0] == 0xcccccccc, "got %#x\n", p32[0] );
ok( p32[1] << 8 == 0xcccccc00, "got %#x\n", p32[1] );
if (flags & HEAP_TAIL_CHECKING_ENABLED)
ok( p32[1] >> 24 == 0xab, "got %#x\n", p32[1] );
ok( p32[2] == 0xbaadf00d, "got %#x\n", p32[2] );
memcpy( &tmp, p + size - 3, 3 );
ok( tmp != 0xadf00d, "got %#x\n", tmp );
ret = pHeapFree( GetProcessHeap(), 0, p );
ok( ret, "failed.\n" );
}
I think this would be simpler, the loops seem unnecessary. I removed the non-inplace check with 0xba, as I don't think it is reliable and hopefully doesn't matter? -- https://gitlab.winehq.org/wine/wine/-/merge_requests/3379#note_40129