ReactOS 0.4.15-dev-7968-g24a56f8
RtlGetProcessHeaps.c File Reference
#include "precomp.h"
Include dependency graph for RtlGetProcessHeaps.c:

Go to the source code of this file.

Functions

 START_TEST (RtlGetProcessHeaps)
 

Function Documentation

◆ START_TEST()

START_TEST ( RtlGetProcessHeaps  )

Definition at line 10 of file RtlGetProcessHeaps.c.

11{
12 HANDLE HeapArray[40] = {0};
13 ULONG MaxHeapArraySize = _countof(HeapArray);
14
15 // Can call it with NULL
16 ULONG InitialNumHeaps = RtlGetProcessHeaps(0, NULL);
17 ok(InitialNumHeaps > 0, "Expected at least one heap\n");
18 ok(InitialNumHeaps < MaxHeapArraySize, "Expected less heaps, got %lu\n", InitialNumHeaps);
19
20 // Grab all heaps
21 ULONG NumHeaps = RtlGetProcessHeaps(MaxHeapArraySize, HeapArray);
22 ok_eq_ulong(NumHeaps, InitialNumHeaps);
23 for (ULONG n = 0; n < min(NumHeaps, MaxHeapArraySize); ++n)
24 {
25 ok(HeapArray[n] != NULL, "Heap[%lu] == NULL\n", n);
26 }
27
28 PVOID HeapPtr = RtlCreateHeap(HEAP_GROWABLE, NULL, 0, 0x10000, NULL, NULL);
29
30 memset(HeapArray, 0, sizeof(HeapArray));
31 NumHeaps = RtlGetProcessHeaps(MaxHeapArraySize, HeapArray);
32 ok_eq_ulong(InitialNumHeaps + 1, NumHeaps);
33 if (NumHeaps > 0 && NumHeaps <= MaxHeapArraySize)
34 {
35 // A new heap is added at the end
36 ok_ptr(HeapArray[NumHeaps - 1], HeapPtr);
37 }
38
39 RtlDestroyHeap(HeapPtr);
40
41 // Just ask for one heap, the number of heaps available is returned, but only one heap ptr filled!
42 memset(HeapArray, 0xff, sizeof(HeapArray));
43 NumHeaps = RtlGetProcessHeaps(1, HeapArray);
44 ok_eq_ulong(NumHeaps, InitialNumHeaps);
45
46 ok_ptr(HeapArray[0], RtlGetProcessHeap()); // First item is the process heap
47 ok_ptr(HeapArray[1], INVALID_HANDLE_VALUE); // Next item is not touched!
48}
#define ok_eq_ulong(value, expected)
Definition: apitest.h:63
#define ok(value,...)
Definition: atltest.h:57
#define ok_ptr(expression, result)
Definition: atltest.h:108
#define NULL
Definition: types.h:112
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
GLdouble n
Definition: glext.h:7729
NTSYSAPI ULONG WINAPI RtlGetProcessHeaps(ULONG, HANDLE *)
#define min(a, b)
Definition: monoChain.cc:55
NTSYSAPI PVOID NTAPI RtlDestroyHeap(IN PVOID HeapHandle)
NTSYSAPI PVOID NTAPI RtlCreateHeap(IN ULONG Flags, IN PVOID HeapBase OPTIONAL, IN ULONG ReserveSize OPTIONAL, IN ULONG CommitSize OPTIONAL, IN PVOID Lock OPTIONAL, IN PRTL_HEAP_PARAMETERS Parameters OPTIONAL)
#define HEAP_GROWABLE
Definition: nt_native.h:1693
#define memset(x, y, z)
Definition: compat.h:39
#define _countof(array)
Definition: sndvol32.h:68
uint32_t ULONG
Definition: typedefs.h:59