fbxsdk/core/base/fbxcontainerallocators.h Source File
         
    
Go to the documentation of this file.
   13 #ifndef _FBXSDK_CORE_BASE_CONTAINER_ALLOCATORS_H_ 
   14 #define _FBXSDK_CORE_BASE_CONTAINER_ALLOCATORS_H_ 
   33         mRecordSize(pRecordSize)
 
   56         return FbxMalloc(pRecordCount * mRecordSize);
 
   86         mRecordSize(pRecordSize),
 
   93         mRecordSize(pOther.mRecordSize),
 
   94         mRecordPoolSize(pOther.mRecordPoolSize),
 
  101         MemoryBlock* lCurrent = mData;
 
  102         MemoryBlock* lNext = lCurrent ? lCurrent->mNextBlock : 0;
 
  107             lNext = lCurrent ? lCurrent->mNextBlock : 0;
 
  113         MemoryBlock* lMem = FbxNew< MemoryBlock >(pRecordCount* mRecordSize);
 
  114         lMem->mNextBlock = mData;
 
  116         mRecordPoolSize += pRecordCount;
 
  121         MemoryBlock* lBlock = mData;
 
  122         void* lRecord = 
NULL;
 
  124         while( (lBlock != 
NULL) && ((lRecord = lBlock->GetChunk(pRecordCount * mRecordSize)) == 
NULL) )
 
  126             lBlock = lBlock->mNextBlock;
 
  129         if( lRecord == 
NULL )
 
  131             size_t lNumRecordToAllocate = mRecordPoolSize / 8 == 0 ? 2 : mRecordPoolSize / 8;
 
  132             if( lNumRecordToAllocate < pRecordCount )
 
  134                 lNumRecordToAllocate = pRecordCount;
 
  154         if( 
this != &pOther )
 
  159             if( mRecordSize < pOther.mRecordSize )
 
  164             mRecordSize = pOther.mRecordSize;
 
  173         MemoryBlock(
size_t pSize) :
 
  179             mData = FbxMalloc(pSize);
 
  181             mEnd = 
reinterpret_cast<char*
>(mData) + pSize;
 
  189         void* GetChunk(
const size_t pSize)
 
  191             if( reinterpret_cast<char*>(mFreeData) + pSize < mEnd )
 
  193                 void* lChunk = mFreeData;
 
  194                 mFreeData = 
reinterpret_cast<char*
>(mFreeData) + pSize;
 
  200         MemoryBlock*    mNextBlock;
 
  207     size_t          mRecordPoolSize;
 
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...