2 * PROJECT: ReactOS api tests
3 * LICENSE: GPLv2+ - See COPYING in the top level directory
4 * PURPOSE: Test for RtlAllocateHeap
5 * PROGRAMMER: Pierre Schweitzer <pierre@reactos.org>
10 #define WIN32_NO_STATUS
11 #include <ndk/rtlfuncs.h>
15 START_TEST(RtlAllocateHeap
)
19 BOOLEAN Aligned
= TRUE
;
20 RTL_HEAP_PARAMETERS Parameters
= {0};
22 for (i
= 0; i
< 0x100; ++i
)
24 Buffers
[i
] = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_CREATE_ALIGN_16
, (i
% 16 ) + 1);
25 ASSERT(Buffers
[i
] != NULL
);
26 if (!((ULONG_PTR
)Buffers
[i
] & 0xF))
32 for (i
= 0; i
< 0x100; ++i
)
34 RtlFreeHeap(RtlGetProcessHeap(), 0, Buffers
[i
]);
37 ok(Aligned
== FALSE
, "No unaligned address returned\n");
40 Parameters
.Length
= sizeof(Parameters
);
41 hHeap
= RtlCreateHeap(HEAP_CREATE_ALIGN_16
, NULL
, 0, 0, NULL
, &Parameters
);
47 for (i
= 0; i
< 0x100; ++i
)
49 Buffers
[i
] = RtlAllocateHeap(hHeap
, 0, (i
% 16 ) + 1);
50 ASSERT(Buffers
[i
] != NULL
);
51 if (!((ULONG_PTR
)Buffers
[i
] & 0xF))
57 for (i
= 0; i
< 0x100; ++i
)
59 RtlFreeHeap(hHeap
, 0, Buffers
[i
]);
62 RtlDestroyHeap(hHeap
);
64 ok(Aligned
== TRUE
, "Unaligned address returned\n");
68 hHeap
= RtlCreateHeap(HEAP_CREATE_ALIGN_16
, NULL
, 0, 0, NULL
, (PRTL_HEAP_PARAMETERS
)0xdeadbeef);
70 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
72 hHeap
= INVALID_HANDLE_VALUE
;
76 ok(hHeap
== NULL
, "Unexpected heap value: %p\n", hHeap
);