17#define TEST_ALLOC(ret_expected,err_expected,threw_excepted,HeapHandle,Flags,Size,Count,Array) \
21 ret = g_alloc((HeapHandle), (Flags), (Size), (Count), (Array)); \
22 err = GetLastError(); \
23 } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { \
24 threw = _SEH2_GetExceptionCode(); \
27 ok((ret) == (ret_expected), "ret excepted %d, but %d\n", (ret_expected), (ret)); \
28 ok((err) == (err_expected), "err excepted %d, but %d\n", (err_expected), (err)); \
29 ok((threw) == (threw_excepted), "threw excepted %d, but %d\n", (threw_excepted), (threw));
31#define TEST_ALLOC_NO_RET(err_expected,threw_excepted,HeapHandle,Flags,Size,Count,Array) \
35 ret = g_alloc((HeapHandle), (Flags), (Size), (Count), (Array)); \
36 err = GetLastError(); \
37 } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { \
38 threw = _SEH2_GetExceptionCode(); \
41 ok((err) == (err_expected), "err excepted %d, but %d", (err_expected), (err)); \
42 ok((threw) == (threw_excepted), "threw excepted %d, but %d\n", (threw_excepted), (threw));
44#define TEST_FREE(ret_expected,err_expected,threw_excepted,HeapHandle,Flags,Count,Array) \
48 ret = g_free((HeapHandle), (Flags), (Count), (Array)); \
49 err = GetLastError(); \
50 } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { \
51 threw = _SEH2_GetExceptionCode(); \
54 ok((ret) == (ret_expected), "ret excepted %d, but %d\n", (ret_expected), (ret)); \
55 ok((err) == (err_expected), "err excepted %d, but %d\n", (err_expected), (err)); \
56 ok((threw) == (threw_excepted), "threw excepted %d, but %d\n", (threw_excepted), (threw));
58#define ASSUME_ARRAY_ITEMS_ARE_NULL() \
59 ok(Array[0] == NULL, "Array[0] is expected as NULL\n"); \
60 ok(Array[1] == NULL, "Array[1] is expected as NULL\n"); \
61 ok(Array[2] == NULL, "Array[2] is expected as NULL\n");
63#define INT_EXPECTED(var,value) \
64 ok((var) == (value), #var " expected %d, but %d\n", (value), (var))
89 TEST_ALLOC(0, -1, 0, HeapHandle, 0, 0, 0, Array);
93 TEST_ALLOC(1, -1, 0, HeapHandle, 0, 0, 1, Array);
94 ok(Array[0] !=
NULL,
"Array[0] is expected as non-NULL\n");
95 ok(Array[1] ==
NULL,
"Array[1] is expected as NULL\n");
96 ok(Array[2] ==
NULL,
"Array[2] is expected as NULL\n");
99 TEST_ALLOC(0, -1, 0, HeapHandle, 0, 1, 0, Array);
103 TEST_ALLOC(1, -1, 0, HeapHandle, 0, 1, 1, Array);
104 ok(Array[0] !=
NULL,
"Array[0] is expected as non-NULL\n");
105 ok(Array[1] ==
NULL,
"Array[1] is expected as NULL\n");
106 ok(Array[2] ==
NULL,
"Array[2] is expected as NULL\n");
109 TEST_ALLOC(2, -1, 0, HeapHandle, 0, 1, 2, Array);
110 ok(Array[0] !=
NULL,
"Array[0] is expected as non-NULL\n");
111 ok(Array[1] !=
NULL,
"Array[1] is expected as non-NULL\n");
112 ok(Array[2] ==
NULL,
"Array[2] is expected as NULL\n");
115 TEST_ALLOC(3, -1, 0, HeapHandle, 0, 1, 3, Array);
116 ok(Array[0] !=
NULL,
"Array[0] is expected as non-NULL\n");
117 ok(Array[1] !=
NULL,
"Array[1] is expected as non-NULL\n");
118 ok(Array[2] !=
NULL,
"Array[2] is expected as non-NULL\n");
122 TEST_ALLOC(0, -1, 0, HeapHandle, 0, 0, 0, Array);
123 ok(Array[0] == (
PVOID)1,
"Array[0] is expected as 1\n");
124 ok(Array[1] == (
PVOID)2,
"Array[1] is expected as 2\n");
125 ok(Array[2] == (
PVOID)3,
"Array[2] is expected as 3\n");
128 TEST_ALLOC(1, -1, 0, HeapHandle, 0, 0, 1, Array);
129 ok(Array[0] !=
NULL,
"Array[0] is expected as non-NULL\n");
130 ok(Array[1] == (
PVOID)2,
"Array[1] is expected as 2\n");
131 ok(Array[2] == (
PVOID)3,
"Array[2] is expected as 3\n");
134 TEST_ALLOC(0, -1, 0, HeapHandle, 0, 1, 0, Array);
135 ok(Array[0] == (
PVOID)1,
"Array[0] is expected as 1\n");
136 ok(Array[1] == (
PVOID)2,
"Array[1] is expected as 2\n");
137 ok(Array[2] == (
PVOID)3,
"Array[2] is expected as 3\n");
140 TEST_ALLOC(1, -1, 0, HeapHandle, 0, 1, 1, Array);
141 ok(Array[0] !=
NULL,
"Array[0] is expected as non-NULL\n");
142 ok(Array[1] == (
PVOID)2,
"Array[1] is expected as non-NULL\n");
143 ok(Array[2] == (
PVOID)3,
"Array[2] is expected as NULL\n");
146 TEST_ALLOC(2, -1, 0, HeapHandle, 0, 1, 2, Array);
147 ok(Array[0] !=
NULL,
"Array[0] is expected as non-NULL\n");
148 ok(Array[1] !=
NULL,
"Array[1] is expected as non-NULL\n");
149 ok(Array[2] == (
PVOID)3,
"Array[2] is expected as 3\n");
152 TEST_ALLOC(3, -1, 0, HeapHandle, 0, 1, 3, Array);
153 ok(Array[0] !=
NULL,
"Array[0] is expected as non-NULL\n");
154 ok(Array[1] !=
NULL,
"Array[1] is expected as non-NULL\n");
155 ok(Array[2] !=
NULL,
"Array[2] is expected as non-NULL\n");
160 ok(
ret != 3,
"excepted not allocated");
163 ok(
ret != 3,
"excepted not allocated");
182 TEST_FREE(0, -1, 0, HeapHandle, 0, 0, Array);
184 TEST_FREE(1, -1, 0, HeapHandle, 0, 1, Array);
186 TEST_FREE(2, -1, 0, HeapHandle, 0, 2, Array);
188 TEST_FREE(3, -1, 0, HeapHandle, 0, 3, Array);
192 TEST_FREE(0, -1, 0, HeapHandle, 0, 0, Array);
204 TEST_FREE(0, -1, 0, HeapHandle, 0, 0, Array);
209 TEST_FREE(1, -1, 0, HeapHandle, 0, 1, Array);
214 TEST_FREE(2, -1, 0, HeapHandle, 0, 2, Array);
219 TEST_FREE(3, -1, 0, HeapHandle, 0, 3, Array);
225 TEST_FREE(0, -1, 0, HeapHandle, 0, 0, Array);
230 TEST_FREE(1, -1, 0, HeapHandle, 0, 1, Array);
267 TEST_FREE(3, -1, 0, HeapHandle, 0, 3, Array);
279 skip(
"RtlMultipleAllocateHeap or RtlMultipleFreeHeap not found\n");
#define INT_EXPECTED(var, value)
#define TEST_FREE(ret_expected, err_expected, threw_excepted, HeapHandle, Flags, Count, Array)
ULONG(NTAPI * FN_RtlMultipleAllocateHeap)(IN PVOID, IN ULONG, IN SIZE_T, IN ULONG, OUT PVOID *)
static FN_RtlMultipleFreeHeap g_free
#define TEST_ALLOC_NO_RET(err_expected, threw_excepted, HeapHandle, Flags, Size, Count, Array)
static FN_RtlMultipleAllocateHeap g_alloc
static void MultiHeapAllocTest()
static void MultiHeapFreeTest()
#define ASSUME_ARRAY_ITEMS_ARE_NULL()
ULONG(NTAPI * FN_RtlMultipleFreeHeap)(IN PVOID, IN ULONG, IN ULONG, OUT PVOID *)
#define TEST_ALLOC(ret_expected, err_expected, threw_excepted, HeapHandle, Flags, Size, Count, Array)
static void set_array(PVOID *array, PVOID p0, PVOID p1, PVOID p2)
#define ERROR_NOT_ENOUGH_MEMORY
#define ERROR_INVALID_PARAMETER
#define GetProcAddress(x, y)
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
#define HEAP_GENERATE_EXCEPTIONS
ULONG NTAPI RtlMultipleAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size, IN ULONG Count, OUT PVOID *Array)