7 #ifndef _POOLALLOC_INCLUDED_
8 #define _POOLALLOC_INCLUDED_
11 #define GUARD_BLOCKS // define to enable guard block sanity checking
46 size(size), mem(mem), prevAlloc(prev) {
53 memset(preGuard(), guardBlockBeginVal, guardBlockSize);
55 memset(postGuard(), guardBlockEndVal, guardBlockSize);
60 checkGuardBlock(preGuard(), guardBlockBeginVal,
"before");
61 checkGuardBlock(postGuard(), guardBlockEndVal,
"after");
69 return size + 2 * guardBlockSize + headerSize();
74 return m + guardBlockSize + headerSize();
78 void checkGuardBlock(
unsigned char* blockMem,
unsigned char val,
const char* locText)
const;
81 unsigned char* preGuard()
const {
return mem + headerSize(); }
82 unsigned char*
data()
const {
return preGuard() + guardBlockSize; }
83 unsigned char* postGuard()
const {
return data() +
size; }
90 const static unsigned char guardBlockBeginVal;
91 const static unsigned char guardBlockEndVal;
92 const static unsigned char userDataFill;
94 const static size_t guardBlockSize;
96 inline static size_t headerSize() {
return sizeof(
TAllocation); }
98 inline static size_t headerSize() {
return 0; }
118 TPoolAllocator(
int growthIncrement = 8*1024,
int allocationAlignment = 16);
170 lastAllocation->checkAllocList();
190 new(memory)
TAllocation(numBytes, memory, block->lastAllocation);
191 block->lastAllocation =
reinterpret_cast<TAllocation*
>(memory);
243 template<
class Other>
254 template <
class Other>
260 template<
class Other>
263 #if defined(__SUNPRO_CC) && !defined(_RWSTD_ALLOCATOR)
282 #endif // _RWSTD_ALLOCATOR
300 #endif // _POOLALLOC_INCLUDED_
void * allocate(size_t numBytes)
bool operator==(const pool_allocator &rhs) const
GLuint const GLfloat * val
void setAllocator(TPoolAllocator *a)
ptrdiff_t difference_type
TPoolAllocator * GetGlobalPoolAllocator()
static size_t allocationSize(size_t size)
static unsigned char * offsetAllocation(unsigned char *m)
pointer allocate(size_type n, const void *)
GLboolean GLboolean GLboolean GLboolean a
TPoolAllocator * allocator
pool_allocator(const pool_allocator< T > &p)
pool_allocator(TPoolAllocator &a)
void checkAllocList() const
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
pointer address(reference x) const
TAllocation(size_t size, unsigned char *mem, TAllocation *prev=0)
TPoolAllocator & getAllocator() const
size_type max_size(int size) const
const_pointer address(const_reference x) const
const T & const_reference
void SetGlobalPoolAllocator(TPoolAllocator *poolAllocator)
void deallocate(pointer, size_type)
TPoolAllocator(int growthIncrement=8 *1024, int allocationAlignment=16)
pool_allocator< T > & operator=(const pool_allocator< Other > &p)
pool_allocator(const pool_allocator< Other > &p)
bool operator!=(const pool_allocator &rhs) const
void * initializeAllocation(tHeader *block, unsigned char *memory, size_t numBytes)
pointer allocate(size_type n)
size_type max_size() const
pool_allocator< Other > other
std::vector< tAllocState > tAllocStack
void construct(pointer p, const T &val)