ReactOS  0.4.15-dev-5455-g015cd25
CHeapPtrList.cpp File Reference
#include "atltest.h"
#include <atlcoll.h>
Include dependency graph for CHeapPtrList.cpp:

Go to the source code of this file.

Classes

class  CComHeapPtrList< T >
 
struct  CHeapPtrListMallocSpy
 

Functions

static PDWORD test_Alloc (DWORD value)
 
 START_TEST (CHeapPtrList)
 

Variables

static LONG g_OpenAllocations = 0
 
static LONG g_Reallocations = 0
 
static CHeapPtrListMallocSpy g_Spy
 

Function Documentation

◆ START_TEST()

START_TEST ( CHeapPtrList  )

Definition at line 87 of file CHeapPtrList.cpp.

88 {
90  ok(SUCCEEDED(hr), "Expected CoRegisterMallocSpy to succeed, but it failed: 0x%lx\n", hr);
91 
92  {
93  ok(g_OpenAllocations == 0, "Expected there to be 0 allocations, was: %ld\n", g_OpenAllocations);
94  CComHeapPtrList<DWORD> heapPtr1;
95  ok(g_OpenAllocations == 0, "Expected there to be 0 allocations, was: %ld\n", g_OpenAllocations);
96  PDWORD Ptr = test_Alloc(0x11111111);
97  ok(g_OpenAllocations == 1, "Expected there to be 1 allocations, was: %ld\n", g_OpenAllocations);
99  ok(g_OpenAllocations == 1, "Expected there to be 1 allocations, was: %ld\n", g_OpenAllocations);
100  heapPtr1.AddTail(tmp);
101  ok(tmp.m_pData == NULL, "Expected m_pData to be transfered\n");
102  ok(g_OpenAllocations == 1, "Expected there to be 1 allocations, was: %ld\n", g_OpenAllocations);
103  Ptr = test_Alloc(0x22222222);
104  ok(g_OpenAllocations == 2, "Expected there to be 1 allocations, was: %ld\n", g_OpenAllocations);
105 #if defined(_MSC_VER) && !defined(__clang__)
106  heapPtr1.AddTail(CComHeapPtr<DWORD>(Ptr));
107 #else
108  CComHeapPtr<DWORD> xxx(Ptr);
109  heapPtr1.AddTail(xxx);
110 #endif
111  ok(g_OpenAllocations == 2, "Expected there to be 1 allocations, was: %ld\n", g_OpenAllocations);
112  }
113  ok(g_OpenAllocations == 0, "Expected there to be 0 allocations, was: %ld\n", g_OpenAllocations);
114 
115  hr = CoRevokeMallocSpy();
116  ok(SUCCEEDED(hr), "Expected CoRevokeMallocSpy to succeed, but it failed: 0x%lx\n", hr);
117 }
HRESULT hr
Definition: shlfolder.c:183
static CHeapPtrListMallocSpy g_Spy
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
HRESULT WINAPI CoRevokeMallocSpy(void)
Definition: ifs.c:522
if SUCCEEDED(hr)
LONG HRESULT
Definition: typedefs.h:79
static LONG g_OpenAllocations
static PDWORD test_Alloc(DWORD value)
#define ok(value,...)
Definition: atltest.h:57
HRESULT WINAPI CoRegisterMallocSpy(LPMALLOCSPY pMallocSpy)
Definition: ifs.c:482
#define NULL
Definition: types.h:112
DWORD * PDWORD
Definition: pedump.c:68

◆ test_Alloc()

static PDWORD test_Alloc ( DWORD  value)
static

Definition at line 16 of file CHeapPtrList.cpp.

17 {
18  PDWORD ptr = (PDWORD)::CoTaskMemAlloc(sizeof(DWORD));
19  *ptr = value;
20  return ptr;
21 }
static PVOID ptr
Definition: dispmode.c:27
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizei const GLfloat * value
Definition: glext.h:6069
DWORD * PDWORD
Definition: pedump.c:68
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426

Referenced by START_TEST().

Variable Documentation

◆ g_OpenAllocations

LONG g_OpenAllocations = 0
static

◆ g_Reallocations

LONG g_Reallocations = 0
static

Definition at line 38 of file CHeapPtrList.cpp.

Referenced by CHeapPtrListMallocSpy::PostRealloc().

◆ g_Spy

CHeapPtrListMallocSpy g_Spy
static

Definition at line 84 of file CHeapPtrList.cpp.

Referenced by START_TEST().