ReactOS  0.4.15-dev-499-g1f31905
CHeapPtr< T, Allocator > Class Template Reference

#include <atlalloc.h>

Collaboration diagram for CHeapPtr< T, Allocator >:

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  :
101  m_pData(NULL)
102  {
103  }
T * m_pData
Definition: atlalloc.h:192
smooth NULL
Definition: ftsmooth.c:416

◆ 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  }
T * m_pData
Definition: atlalloc.h:192

◆ 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 * m_pData
Definition: atlalloc.h:192
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

◆ 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  {
129  ATLASSERT(m_pData == NULL);
130  m_pData = static_cast<T*>(Allocator::Allocate(nBytes));
131  return m_pData != NULL;
132  }
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
T * m_pData
Definition: atlalloc.h:192
_In_opt_ PALLOCATE_FUNCTION Allocate
Definition: exfuncs.h:814
smooth NULL
Definition: ftsmooth.c:416

Referenced by CHeapPtr< T, CComAllocator >::Allocate().

◆ Attach()

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

Definition at line 162 of file atlalloc.h.

163  {
165  m_pData = lp;
166  }
T * m_pData
Definition: atlalloc.h:192
_In_opt_ PALLOCATE_FUNCTION _In_opt_ PFREE_FUNCTION Free
Definition: exfuncs.h:814

Referenced by CHeapPtr< T, CComAllocator >::operator=().

◆ Detach()

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

Definition at line 168 of file atlalloc.h.

169  {
170  T *saveP = m_pData;
171  m_pData = NULL;
172  return saveP;
173  }
T * m_pData
Definition: atlalloc.h:192
#define T
Definition: mbstring.h:31
smooth NULL
Definition: ftsmooth.c:416

Referenced by CHeapPtr< T, CComAllocator >::CHeapPtr(), and CHeapPtr< T, CComAllocator >::operator=().

◆ 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  {
158  m_pData = NULL;
159  }
160  }
T * m_pData
Definition: atlalloc.h:192
_In_opt_ PALLOCATE_FUNCTION _In_opt_ PFREE_FUNCTION Free
Definition: exfuncs.h:814
smooth NULL
Definition: ftsmooth.c:416

Referenced by CHeapPtr< T, CComAllocator >::~CHeapPtr().

◆ operator &()

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

Definition at line 175 of file atlalloc.h.

176  {
177  ATLASSERT(m_pData == NULL);
178  return &m_pData;
179  }
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
T * m_pData
Definition: atlalloc.h:192
smooth NULL
Definition: ftsmooth.c:416

◆ 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  }
T * m_pData
Definition: atlalloc.h:192

◆ 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  }
T * m_pData
Definition: atlalloc.h:192

◆ 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  }
T * m_pData
Definition: atlalloc.h:192
T * Detach()
Definition: atlalloc.h:168
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  }
#define T
Definition: mbstring.h:31
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  }
T * m_pData
Definition: atlalloc.h:192
#define T
Definition: mbstring.h:31
smooth NULL
Definition: ftsmooth.c:416

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

Member Data Documentation

◆ m_pData


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