ReactOS 0.4.15-dev-7942-gd23573b
StackAllocator< _Tp > Struct Template Reference

#include <stack_allocator.h>

Classes

struct  rebind
 

Public Types

typedef _Tp value_type
 
typedef value_typepointer
 
typedef const _Tp * const_pointer
 
typedef _Tp & reference
 
typedef const _Tp & const_reference
 
typedef size_t size_type
 
typedef ptrdiff_t difference_type
 

Public Member Functions

 StackAllocator (char *beg, char *end)
 
const StategetState () const
 
template<class _OtherTp >
 StackAllocator (StackAllocator< _OtherTp > const &other)
 
_Tp * allocate (size_type n, void *=0)
 
void deallocate (pointer p, size_type n)
 
pointer address (reference __x) const
 
const_pointer address (const_reference __x) const
 
size_type max_size () const
 
void construct (pointer __p, const_reference __val)
 
void destroy (pointer __p)
 
bool ok () const
 
void reset ()
 
bool swaped () const
 
void swap (StackAllocator &other)
 
bool operator== (StackAllocator const &other) const
 
bool operator!= (StackAllocator const &other) const
 

Private Attributes

State m_state
 

Detailed Description

template<class _Tp>
struct StackAllocator< _Tp >

Definition at line 47 of file stack_allocator.h.

Member Typedef Documentation

◆ const_pointer

template<class _Tp >
typedef const _Tp* StackAllocator< _Tp >::const_pointer

Definition at line 58 of file stack_allocator.h.

◆ const_reference

template<class _Tp >
typedef const _Tp& StackAllocator< _Tp >::const_reference

Definition at line 60 of file stack_allocator.h.

◆ difference_type

template<class _Tp >
typedef ptrdiff_t StackAllocator< _Tp >::difference_type

Definition at line 62 of file stack_allocator.h.

◆ pointer

template<class _Tp >
typedef value_type* StackAllocator< _Tp >::pointer

Definition at line 57 of file stack_allocator.h.

◆ reference

template<class _Tp >
typedef _Tp& StackAllocator< _Tp >::reference

Definition at line 59 of file stack_allocator.h.

◆ size_type

template<class _Tp >
typedef size_t StackAllocator< _Tp >::size_type

Definition at line 61 of file stack_allocator.h.

◆ value_type

template<class _Tp >
typedef _Tp StackAllocator< _Tp >::value_type

Definition at line 56 of file stack_allocator.h.

Constructor & Destructor Documentation

◆ StackAllocator() [1/2]

template<class _Tp >
StackAllocator< _Tp >::StackAllocator ( char beg,
char end 
)
inline

Definition at line 68 of file stack_allocator.h.

69 : m_state(beg, end) {}
GLuint GLuint end
Definition: gl.h:1545

◆ StackAllocator() [2/2]

template<class _Tp >
template<class _OtherTp >
StackAllocator< _Tp >::StackAllocator ( StackAllocator< _OtherTp > const other)
inline

Definition at line 74 of file stack_allocator.h.

75 : m_state(other.getState()) {}
int other
Definition: msacm.c:1376

Member Function Documentation

◆ address() [1/2]

template<class _Tp >
const_pointer StackAllocator< _Tp >::address ( const_reference  __x) const
inline

Definition at line 136 of file stack_allocator.h.

136{ return &__x; }

◆ address() [2/2]

template<class _Tp >
pointer StackAllocator< _Tp >::address ( reference  __x) const
inline

Definition at line 135 of file stack_allocator.h.

135{return &__x;}

◆ allocate()

template<class _Tp >
_Tp * StackAllocator< _Tp >::allocate ( size_type  n,
void = 0 
)
inline

Definition at line 88 of file stack_allocator.h.

88 {
89 if (n == 0)
90 return 0;
91
93
94 if (*m_state.m_sharedCur + (n * sizeof(_Tp)) < m_state.m_end) {
95 char *ret = *m_state.m_sharedCur;
96 *m_state.m_sharedCur += n * sizeof(_Tp);
97 return reinterpret_cast<_Tp*>(ret);
98 }
99#if !defined (STLPORT) || defined (_STLP_USE_EXCEPTIONS)
100 throw __STD bad_alloc();
101# if defined (__DMC__)
102 return 0;
103# endif
104#else
105 return 0;
106#endif
107 }
GLdouble n
Definition: glext.h:7729
#define __STD
int * m_sharedNbAlloc
char * m_end
char ** m_sharedCur
int ret

◆ construct()

template<class _Tp >
void StackAllocator< _Tp >::construct ( pointer  __p,
const_reference  __val 
)
inline

Definition at line 138 of file stack_allocator.h.

138{ new(__p) _Tp(__val); }
_STLP_INLINE_LOOP _InputIter const _Tp & __val
Definition: _algobase.h:656

◆ deallocate()

template<class _Tp >
void StackAllocator< _Tp >::deallocate ( pointer  p,
size_type  n 
)
inline

Definition at line 119 of file stack_allocator.h.

119 {
120 if (p == 0)
121 return;
122
124
125 if ((char*)p == (*m_state.m_sharedCur - n * sizeof(_Tp))) {
126 *m_state.m_sharedCur -= n * sizeof(_Tp);
127 }
128
129 if ((char*)p < m_state.m_beg || (char*)p >= m_state.m_end) {
130 //An object has been returned to the bad allocator instance:
131 *m_state.m_sharedOk = false;
132 }
133 }
GLfloat GLfloat p
Definition: glext.h:8902
bool * m_sharedOk
char * m_beg

◆ destroy()

template<class _Tp >
void StackAllocator< _Tp >::destroy ( pointer  __p)
inline

Definition at line 139 of file stack_allocator.h.

139{ __p->~_Tp(); }

◆ getState()

template<class _Tp >
const State & StackAllocator< _Tp >::getState ( ) const
inline

Definition at line 71 of file stack_allocator.h.

71{ return m_state; }

◆ max_size()

template<class _Tp >
size_type StackAllocator< _Tp >::max_size ( ) const
inline

Definition at line 137 of file stack_allocator.h.

137{ return m_state.m_end - *m_state.m_sharedCur; }

◆ ok()

◆ operator!=()

template<class _Tp >
bool StackAllocator< _Tp >::operator!= ( StackAllocator< _Tp > const other) const
inline

Definition at line 163 of file stack_allocator.h.

164 { return !(*this == other); }

◆ operator==()

template<class _Tp >
bool StackAllocator< _Tp >::operator== ( StackAllocator< _Tp > const other) const
inline

Definition at line 160 of file stack_allocator.h.

161 { return m_state.m_beg == other.m_state.m_beg; }

◆ reset()

◆ swap()

template<class _Tp >
void StackAllocator< _Tp >::swap ( StackAllocator< _Tp > &  other)
inline

Definition at line 148 of file stack_allocator.h.

148 {
149 __STD swap(m_state, other.m_state);
150 m_state.m_swaped = true;
151 other.m_state.m_swaped = true;
152 }
#define swap(a, b)
Definition: qsort.c:63

Referenced by std::swap().

◆ swaped()

template<class _Tp >
bool StackAllocator< _Tp >::swaped ( ) const
inline

Definition at line 147 of file stack_allocator.h.

147{ return m_state.m_swaped; }

Member Data Documentation

◆ m_state

template<class _Tp >
State StackAllocator< _Tp >::m_state
private

Definition at line 167 of file stack_allocator.h.

Referenced by StackAllocator< _Tp >::getState().


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