53 pageSize(growthIncrement),
54 alignment(allocationAlignment),
77 size_t minAlign =
sizeof(
void*);
101 delete []
reinterpret_cast<char*
>(
inUseList);
111 delete []
reinterpret_cast<char*
>(
freeList);
117 const unsigned char TAllocation::guardBlockBeginVal = 0xfb;
118 const unsigned char TAllocation::guardBlockEndVal = 0xfe;
119 const unsigned char TAllocation::userDataFill = 0xcd;
122 const size_t TAllocation::guardBlockSize = 16;
124 const size_t TAllocation::guardBlockSize = 0;
130 void TAllocation::checkGuardBlock(
unsigned char* blockMem,
unsigned char val,
const char* locText)
const
133 for (
size_t x = 0;
x < guardBlockSize;
x++) {
134 if (blockMem[
x] != val) {
138 #if defined(_MSC_VER)
139 snprintf(assertMsg,
sizeof(assertMsg),
"PoolAlloc: Damage %s %Iu byte allocation at 0x%p\n",
142 snprintf(assertMsg,
sizeof(assertMsg),
"PoolAlloc: Damage %s %zu byte allocation at 0x%p\n",
145 assert(0 &&
"PoolAlloc: Damage in guard block");
156 stack.push_back(state);
173 if (
stack.size() < 1)
185 delete []
reinterpret_cast<char*
>(
inUseList);
202 while (
stack.size() > 0)
221 if (allocationSize < numBytes)
244 size_t numBytesToAlloc = allocationSize +
headerSkip;
246 if (numBytesToAlloc < allocationSize)
249 tHeader* memory =
reinterpret_cast<tHeader*
>(::new
char[numBytesToAlloc]);
260 return reinterpret_cast<void*
>(
reinterpret_cast<uintptr_t>(memory) + headerSkip);
292 for (
const TAllocation* alloc =
this; alloc != 0; alloc = alloc->prevAlloc)
void * allocate(size_t numBytes)
GLuint const GLfloat * val
TPoolAllocator * GetGlobalPoolAllocator()
static size_t allocationSize(size_t size)
bool InitializePoolIndex()
GLboolean GLboolean GLboolean GLboolean a
bool OS_FreeTLSIndex(OS_TLSIndex nIndex)
void checkAllocList() const
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue)
void SetGlobalPoolAllocator(TPoolAllocator *poolAllocator)
TPoolAllocator(int growthIncrement=8 *1024, int allocationAlignment=16)
OS_TLSIndex OS_AllocTLSIndex()
void * initializeAllocation(tHeader *block, unsigned char *memory, size_t numBytes)
void * OS_GetTLSValue(OS_TLSIndex nIndex)