ReactOS  0.4.14-dev-1115-gebeeb9d
RtlAllocateHeap.c
Go to the documentation of this file.
1 /*
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>
6  */
7 
8 #include "precomp.h"
9 
10 PVOID Buffers[0x100];
11 
13 {
14  USHORT i;
15  HANDLE hHeap;
16  BOOLEAN Aligned = TRUE;
18 
19  for (i = 0; i < 0x100; ++i)
20  {
21  Buffers[i] = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_CREATE_ALIGN_16, (i % 16 ) + 1);
22  ASSERT(Buffers[i] != NULL);
23  if (!((ULONG_PTR)Buffers[i] & 0xF))
24  {
25  Aligned = FALSE;
26  }
27  }
28 
29  for (i = 0; i < 0x100; ++i)
30  {
31  RtlFreeHeap(RtlGetProcessHeap(), 0, Buffers[i]);
32  }
33 
34  ok(Aligned == FALSE, "No unaligned address returned\n");
35 
36  Aligned = TRUE;
37  Parameters.Length = sizeof(Parameters);
39  if (hHeap == NULL)
40  {
41  return;
42  }
43 
44  for (i = 0; i < 0x100; ++i)
45  {
46  Buffers[i] = RtlAllocateHeap(hHeap, 0, (i % 16 ) + 1);
47  ASSERT(Buffers[i] != NULL);
48  if (!((ULONG_PTR)Buffers[i] & 0xF))
49  {
50  Aligned = FALSE;
51  }
52  }
53 
54  for (i = 0; i < 0x100; ++i)
55  {
56  RtlFreeHeap(hHeap, 0, Buffers[i]);
57  }
58 
59  RtlDestroyHeap(hHeap);
60 
61  ok(Aligned == TRUE, "Unaligned address returned\n");
62 
63  _SEH2_TRY
64  {
65  hHeap = RtlCreateHeap(HEAP_CREATE_ALIGN_16, NULL, 0, 0, NULL, (PRTL_HEAP_PARAMETERS)(ULONG_PTR)0xdeadbeefdeadbeefULL);
66  }
68  {
69  hHeap = INVALID_HANDLE_VALUE;
70  }
71  _SEH2_END;
72 
73  ok(hHeap == NULL, "Unexpected heap value: %p\n", hHeap);
74 }
#define TRUE
Definition: types.h:120
START_TEST(RtlAllocateHeap)
#define HEAP_CREATE_ALIGN_16
Definition: nt_native.h:1701
PVOID Buffers[0x100]
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
_SEH2_TRY
Definition: create.c:4250
uint32_t ULONG_PTR
Definition: typedefs.h:64
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
NTSYSAPI PVOID NTAPI RtlDestroyHeap(IN PVOID HeapHandle)
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
_In_ PPCI_DEVICE_PRESENCE_PARAMETERS Parameters
Definition: iotypes.h:872
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)
_SEH2_END
Definition: create.c:4424
unsigned short USHORT
Definition: pedump.c:61
#define ok(value,...)
Definition: atltest.h:57
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6