2 * PROJECT: ReactOS api tests
3 * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
4 * PURPOSE: Test for RtlReAllocateHeap
5 * PROGRAMMERS: Thomas Faber <thomas.faber@reactos.org>
9 #include <ndk/rtlfuncs.h>
18 PUCHAR Array
= Buffer
;
21 for (i
= 0; i
< Size
; i
++)
22 if (Array
[i
] != Value
)
24 trace("Expected %x, found %x at offset %lu\n", Value
, Array
[i
], (ULONG
)i
);
39 SIZE_T OldSize
= *OldSizePtr
;
41 RtlFillMemory(*Buffer
, OldSize
, 0x7a);
42 NewBuffer
= RtlReAllocateHeap(RtlGetProcessHeap(),
48 skip("RtlReAllocateHeap failed for size %lu (%s)\n", Size
, Action
);
52 ok_hex(RtlSizeHeap(RtlGetProcessHeap(), 0, NewBuffer
), Size
);
55 ok(CheckBuffer(NewBuffer
, OldSize
, 0x7a), "CheckBuffer failed at size 0x%lx -> 0x%lx\n", OldSize
, Size
);
56 ok(CheckBuffer(NewBuffer
+ OldSize
, Size
- OldSize
, 0), "HEAP_ZERO_MEMORY not respected for 0x%lx -> 0x%lx\n", OldSize
, Size
);
60 ok(CheckBuffer(NewBuffer
, Size
, 0x7a), "CheckBuffer failed at size 0x%lx -> 0x%lx\n", OldSize
, Size
);
66 START_TEST(RtlReAllocateHeap
)
71 BOOLEAN Continue
= TRUE
;
74 Buffer
= RtlReAllocateHeap(RtlGetProcessHeap(),
78 ok(Buffer
== NULL
, "RtlReAllocateHeap succeeded for NULL\n");
80 RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer
);
82 Buffer
= RtlAllocateHeap(RtlGetProcessHeap(),
87 skip("RtlAllocateHeap failed for size %lu\n", OldSize
);
90 ok(CheckBuffer(Buffer
, OldSize
, 0), "HEAP_ZERO_MEMORY not respected for 0x%lx\n", OldSize
);
92 for (Size
= 0x78000; Size
< 0x90000 && Continue
; Size
+= 0x100)
94 Continue
= ReAllocBuffer(&Buffer
, Size
, &OldSize
, "growing");
98 for (Size
-= 0x100; Size
>= 0x78000 && Continue
; Size
-= 0x100)
100 Continue
= ReAllocBuffer(&Buffer
, Size
, &OldSize
, "shrinking");
102 RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer
);