2015-10-11 21:10:03 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS api tests
|
|
|
|
* LICENSE: GPLv2+ - See COPYING in the top level directory
|
|
|
|
* PURPOSE: Test for RtlAllocateHeap
|
|
|
|
* PROGRAMMER: Pierre Schweitzer <pierre@reactos.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <apitest.h>
|
|
|
|
|
|
|
|
#define WIN32_NO_STATUS
|
|
|
|
#include <ndk/rtlfuncs.h>
|
|
|
|
|
|
|
|
PVOID Buffers[0x100];
|
|
|
|
|
|
|
|
START_TEST(RtlAllocateHeap)
|
|
|
|
{
|
|
|
|
USHORT i;
|
2015-10-11 21:49:16 +00:00
|
|
|
HANDLE hHeap;
|
2015-10-11 21:10:03 +00:00
|
|
|
BOOLEAN Aligned = TRUE;
|
2015-10-11 21:49:16 +00:00
|
|
|
RTL_HEAP_PARAMETERS Parameters = {0};
|
2015-10-11 21:10:03 +00:00
|
|
|
|
|
|
|
for (i = 0; i < 0x100; ++i)
|
|
|
|
{
|
|
|
|
Buffers[i] = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_CREATE_ALIGN_16, (i % 16 ) + 1);
|
|
|
|
ASSERT(Buffers[i] != NULL);
|
2015-10-12 17:43:42 +00:00
|
|
|
if (!((ULONG_PTR)Buffers[i] & 0xF))
|
2015-10-11 21:10:03 +00:00
|
|
|
{
|
|
|
|
Aligned = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < 0x100; ++i)
|
|
|
|
{
|
|
|
|
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffers[i]);
|
|
|
|
}
|
|
|
|
|
2015-10-12 17:43:42 +00:00
|
|
|
ok(Aligned == FALSE, "No unaligned address returned\n");
|
2015-10-11 21:49:16 +00:00
|
|
|
|
|
|
|
Aligned = TRUE;
|
|
|
|
Parameters.Length = sizeof(Parameters);
|
|
|
|
hHeap = RtlCreateHeap(HEAP_CREATE_ALIGN_16, NULL, 0, 0, NULL, &Parameters);
|
|
|
|
if (hHeap == NULL)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < 0x100; ++i)
|
|
|
|
{
|
2015-10-11 21:51:32 +00:00
|
|
|
Buffers[i] = RtlAllocateHeap(hHeap, 0, (i % 16 ) + 1);
|
2015-10-11 21:49:16 +00:00
|
|
|
ASSERT(Buffers[i] != NULL);
|
2015-10-12 17:43:42 +00:00
|
|
|
if (!((ULONG_PTR)Buffers[i] & 0xF))
|
2015-10-11 21:49:16 +00:00
|
|
|
{
|
|
|
|
Aligned = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < 0x100; ++i)
|
|
|
|
{
|
2015-10-11 21:51:32 +00:00
|
|
|
RtlFreeHeap(hHeap, 0, Buffers[i]);
|
2015-10-11 21:49:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
RtlDestroyHeap(hHeap);
|
|
|
|
|
2015-10-12 17:43:42 +00:00
|
|
|
ok(Aligned == TRUE, "Unaligned address returned\n");
|
2016-09-25 16:57:55 +00:00
|
|
|
|
|
|
|
_SEH2_TRY
|
|
|
|
{
|
|
|
|
hHeap = RtlCreateHeap(HEAP_CREATE_ALIGN_16, NULL, 0, 0, NULL, (PRTL_HEAP_PARAMETERS)0xdeadbeef);
|
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
|
|
|
hHeap = INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
_SEH2_END;
|
|
|
|
|
|
|
|
ok(hHeap == NULL, "Unexpected heap value: %p\n", hHeap);
|
2015-10-11 21:10:03 +00:00
|
|
|
}
|