ReactOS 0.4.15-dev-5666-gc548b97
CHeapPtr< T, Allocator > Class Template Reference

#include <atlalloc.h>

Public Member Functions

 CHeapPtr ()
 
 CHeapPtr (T *lp)
 
 CHeapPtr (CHeapPtr< T, Allocator > &lp)
 
 ~CHeapPtr ()
 
CHeapPtr< T, Allocator > & operator= (CHeapPtr< T, Allocator > &lp)
 
bool AllocateBytes (_In_ size_t nBytes)
 
bool ReallocateBytes (_In_ size_t nBytes)
 
bool Allocate (_In_ size_t nElements=1)
 
bool Reallocate (_In_ size_t nElements)
 
void Free ()
 
void Attach (T *lp)
 
TDetach ()
 
T ** operator& ()
 
 operator T* () const
 
Toperator-> () const
 

Public Attributes

Tm_pData
 

Detailed Description

template<class T, class Allocator = CCRTAllocator>
class CHeapPtr< T, Allocator >

Definition at line 97 of file atlalloc.h.

Constructor & Destructor Documentation

◆ CHeapPtr() [1/3]

template<class T , class Allocator = CCRTAllocator>
CHeapPtr< T, Allocator >::CHeapPtr ( )
inline

Definition at line 100 of file atlalloc.h.

100 :
102 {
103 }
T * m_pData
Definition: atlalloc.h:192
#define NULL
Definition: types.h:112

◆ CHeapPtr() [2/3]

template<class T , class Allocator = CCRTAllocator>
CHeapPtr< T, Allocator >::CHeapPtr ( T lp)
inlineexplicit

Definition at line 105 of file atlalloc.h.

105 :
106 m_pData(lp)
107 {
108 }

◆ CHeapPtr() [3/3]

template<class T , class Allocator = CCRTAllocator>
CHeapPtr< T, Allocator >::CHeapPtr ( CHeapPtr< T, Allocator > &  lp)
inlineexplicit

Definition at line 110 of file atlalloc.h.

111 {
112 m_pData = lp.Detach();
113 }
T * Detach()
Definition: atlalloc.h:168

◆ ~CHeapPtr()

template<class T , class Allocator = CCRTAllocator>
CHeapPtr< T, Allocator >::~CHeapPtr ( )
inline

Definition at line 115 of file atlalloc.h.

116 {
117 Free();
118 }
void Free()
Definition: atlalloc.h:153

Member Function Documentation

◆ Allocate()

template<class T , class Allocator = CCRTAllocator>
bool CHeapPtr< T, Allocator >::Allocate ( _In_ size_t  nElements = 1)
inline

Definition at line 143 of file atlalloc.h.

144 {
145 return AllocateBytes(nElements * sizeof(T));
146 }
bool AllocateBytes(_In_ size_t nBytes)
Definition: atlalloc.h:127
#define T
Definition: mbstring.h:31

Referenced by CFindFolder::GetAttributesOf(), CFindFolder::GetUIObjectOf(), and TRASH_PlayEmptyRecycleBinSound().

◆ AllocateBytes()

template<class T , class Allocator = CCRTAllocator>
bool CHeapPtr< T, Allocator >::AllocateBytes ( _In_ size_t  nBytes)
inline

Definition at line 127 of file atlalloc.h.

128 {
130 m_pData = static_cast<T*>(Allocator::Allocate(nBytes));
131 return m_pData != NULL;
132 }
#define ATLASSERT(x)
Definition: CComVariant.cpp:10

Referenced by CHeapPtr< T, Allocator >::Allocate(), and TRASH_PlayEmptyRecycleBinSound().

◆ Attach()

template<class T , class Allocator = CCRTAllocator>
void CHeapPtr< T, Allocator >::Attach ( T lp)
inline

◆ Detach()

◆ Free()

template<class T , class Allocator = CCRTAllocator>
void CHeapPtr< T, Allocator >::Free ( )
inline

Definition at line 153 of file atlalloc.h.

154 {
155 if (m_pData)
156 {
157 Allocator::Free(m_pData);
158 m_pData = NULL;
159 }
160 }

Referenced by CFolderItems::get_Count(), CACListISF::GetDisplayName(), CACListISF::Next(), and CHeapPtr< T, Allocator >::~CHeapPtr().

◆ operator T*()

template<class T , class Allocator = CCRTAllocator>
CHeapPtr< T, Allocator >::operator T* ( ) const
inline

Definition at line 181 of file atlalloc.h.

182 {
183 return m_pData;
184 }

◆ operator&()

template<class T , class Allocator = CCRTAllocator>
T ** CHeapPtr< T, Allocator >::operator& ( )
inline

Definition at line 175 of file atlalloc.h.

176 {
178 return &m_pData;
179 }

◆ operator->()

template<class T , class Allocator = CCRTAllocator>
T * CHeapPtr< T, Allocator >::operator-> ( ) const
inline

Definition at line 186 of file atlalloc.h.

187 {
188 return m_pData;
189 }

◆ operator=()

template<class T , class Allocator = CCRTAllocator>
CHeapPtr< T, Allocator > & CHeapPtr< T, Allocator >::operator= ( CHeapPtr< T, Allocator > &  lp)
inline

Definition at line 120 of file atlalloc.h.

121 {
122 if (lp.m_pData != m_pData)
123 Attach(lp.Detach());
124 return *this;
125 }
void Attach(T *lp)
Definition: atlalloc.h:162

◆ Reallocate()

template<class T , class Allocator = CCRTAllocator>
bool CHeapPtr< T, Allocator >::Reallocate ( _In_ size_t  nElements)
inline

Definition at line 148 of file atlalloc.h.

149 {
150 return ReallocateBytes(nElements * sizeof(T));
151 }
bool ReallocateBytes(_In_ size_t nBytes)
Definition: atlalloc.h:134

◆ ReallocateBytes()

template<class T , class Allocator = CCRTAllocator>
bool CHeapPtr< T, Allocator >::ReallocateBytes ( _In_ size_t  nBytes)
inline

Definition at line 134 of file atlalloc.h.

135 {
136 T* newData = static_cast<T*>(Allocator::Reallocate(m_pData, nBytes));
137 if (newData == NULL)
138 return false;
139 m_pData = newData;
140 return true;
141 }

Referenced by CHeapPtr< T, Allocator >::Reallocate().

Member Data Documentation

◆ m_pData


The documentation for this class was generated from the following file: