13 #ifndef _FBXSDK_CORE_BASE_CONTAINER_ALLOCATORS_H_
14 #define _FBXSDK_CORE_BASE_CONTAINER_ALLOCATORS_H_
20 #if defined(FBXSDK_COMPILER_MSC) && _MSC_VER < 1900
22 #pragma warning(disable : 4512) // to avoid: assignment operator could not be generated
38 mRecordSize(pRecordSize)
61 return FbxMalloc(FbxAllocSize(pRecordCount, mRecordSize));
80 const size_t mRecordSize;
91 mRecordSize(pRecordSize),
98 mRecordSize(pOther.mRecordSize),
99 mRecordPoolSize(pOther.mRecordPoolSize),
106 MemoryBlock* lCurrent = mData;
107 MemoryBlock* lNext = lCurrent ? lCurrent->mNextBlock : 0;
112 lNext = lCurrent ? lCurrent->mNextBlock : 0;
118 MemoryBlock* lMem = FbxNew< MemoryBlock >(pRecordCount* mRecordSize);
119 lMem->mNextBlock = mData;
121 mRecordPoolSize += pRecordCount;
126 MemoryBlock* lBlock = mData;
127 void* lRecord =
NULL;
129 while( (lBlock !=
NULL) && ((lRecord = lBlock->GetChunk(pRecordCount * mRecordSize)) ==
NULL) )
131 lBlock = lBlock->mNextBlock;
134 if( lRecord ==
NULL )
136 size_t lNumRecordToAllocate = mRecordPoolSize / 8 == 0 ? 2 : mRecordPoolSize / 8;
137 if( lNumRecordToAllocate < pRecordCount )
139 lNumRecordToAllocate = pRecordCount;
159 if(
this != &pOther )
164 if( mRecordSize < pOther.mRecordSize )
169 mRecordSize = pOther.mRecordSize;
178 MemoryBlock(
size_t pSize) :
184 mData = FbxMalloc(pSize);
186 mEnd =
reinterpret_cast<char*
>(mData) + pSize;
194 void* GetChunk(
const size_t pSize)
196 if( reinterpret_cast<char*>(mFreeData) + pSize < mEnd )
198 void* lChunk = mFreeData;
199 mFreeData =
reinterpret_cast<char*
>(mFreeData) + pSize;
205 MemoryBlock* mNextBlock;
212 size_t mRecordPoolSize;
216 #if defined(FBXSDK_COMPILER_MSC) && _MSC_VER < 1900
An allocator class for use as a template parameter to one of the container class (FbxMap, FbxSet, FbxDynamicArray...) must implement these.
FBX SDK environment definition.
size_t GetRecordSize() const
void FbxDelete(T *p)
Deletion policy for pointer template classes that uses the FbxDelete() function.
This allocator only frees the allocated memory when it is deleted.
FbxHungryAllocator(size_t pRecordSize)
void FreeMemory(void *pRecord)
Frees a block of memory returned by AllocateRecords.
FbxBaseAllocator(const size_t pRecordSize)
The class constructor.
FbxHungryAllocator & operator=(const FbxHungryAllocator &pOther)
void Reserve(const size_t pRecordCount)
void Reserve(const size_t)
This tells the allocator that we are about to call AllocateRecords one or many times to allocate pRec...
void * AllocateRecords(const size_t pRecordCount=1)
size_t GetRecordSize() const
FbxHungryAllocator(const FbxHungryAllocator &pOther)
void * AllocateRecords(const size_t pRecordCount=1)
Returns a pointer to a uninitialized continuous block of memory able to hold pRecordCount * pRecordSi...