15 #ifndef _BT_POOL_ALLOCATOR_H
16 #define _BT_POOL_ALLOCATOR_H
29 unsigned char* m_pool;
34 : m_elemSize(elemSize),
35 m_maxElements(maxElements)
37 m_pool = (
unsigned char*)
btAlignedAlloc(
static_cast<unsigned int>(m_elemSize * m_maxElements), 16);
39 unsigned char* p = m_pool;
41 m_freeCount = m_maxElements;
42 int count = m_maxElements;
45 *(
void**)p = (p + m_elemSize);
63 return m_maxElements - m_freeCount;
78 void*
result = m_firstFree;
79 if (
NULL != m_firstFree)
81 m_firstFree = *(
void**)m_firstFree;
92 if (((
unsigned char*)
ptr >= m_pool && (
unsigned char*)
ptr < m_pool + m_maxElements * m_elemSize))
104 btAssert((
unsigned char*)
ptr >= m_pool && (
unsigned char*)
ptr < m_pool + m_maxElements * m_elemSize);
107 *(
void**)
ptr = m_firstFree;
#define btAlignedFree(ptr)
#define btAlignedAlloc(size, alignment)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
SIMD_FORCE_INLINE void btMutexUnlock(btSpinMutex *mutex)
SIMD_FORCE_INLINE void btMutexLock(btSpinMutex *mutex)
The btPoolAllocator class allows to efficiently allocate a large pool of objects, instead of dynamica...
btPoolAllocator(int elemSize, int maxElements)
void freeMemory(void *ptr)
int getElementSize() const
unsigned char * getPoolAddress()
const unsigned char * getPoolAddress() const
void * allocate(int size)
SyclQueue void void size_t num_bytes void