Fixed: Replace free methods by freeBlock to avoid clash with free macros

This commit is contained in:
kervala 2016-12-04 15:55:00 +01:00
parent 554d782150
commit 34eced40f7
21 changed files with 41 additions and 41 deletions

View file

@ -654,7 +654,7 @@ template<class T> typename CQuadGrid<T>::CIterator CQuadGrid<T>::erase(typename
if(!ptr->Selected) if(!ptr->Selected)
next= NULL; next= NULL;
// delete the object. // delete the object.
_NodeBlockMemory.free(ptr); _NodeBlockMemory.freeBlock(ptr);
return CIterator((CNode*)next); return CIterator((CNode*)next);

View file

@ -140,7 +140,7 @@ public:
private: private:
void clearTile (CTile::TBitmap type); void clearTile (CTile::TBitmap type);
void free () void freeBlock ()
{ {
nlassert ((_Flags&=NL3D_CTILE_FREE_FLAG)==0); nlassert ((_Flags&=NL3D_CTILE_FREE_FLAG)==0);
_Flags|=NL3D_CTILE_FREE_FLAG; _Flags|=NL3D_CTILE_FREE_FLAG;

View file

@ -69,7 +69,7 @@ public:
bool allocate(uint numVertices, uint &indexStart); bool allocate(uint numVertices, uint &indexStart);
/// free a subset of the VB. nlstop if subset not found... /// free a subset of the VB. nlstop if subset not found...
void free(uint indexStart); void freeBlock(uint indexStart);
// @} // @}

View file

@ -132,7 +132,7 @@ public:
} }
/// delete an element allocated with this manager. dtor is called. NULL is tested. /// delete an element allocated with this manager. dtor is called. NULL is tested.
void free(T* ptr) void freeBlock(T* ptr)
{ {
if(!ptr) if(!ptr)
return; return;

View file

@ -55,7 +55,7 @@ public:
// allocated a block of n bytes // allocated a block of n bytes
void *alloc(uint numBytes); void *alloc(uint numBytes);
// deallocate a block // deallocate a block
void free(void *block, uint numBytes); void freeBlock(void *block, uint numBytes);
// compute the total number of bytes allocated since init // compute the total number of bytes allocated since init
// NB : freed block are not subtracted from that total !! // NB : freed block are not subtracted from that total !!
uint getNumAllocatedBytes() const { return _NumAllocatedBytes; } uint getNumAllocatedBytes() const { return _NumAllocatedBytes; }

View file

@ -45,7 +45,7 @@ public:
/// alloc a block /// alloc a block
void *alloc(); void *alloc();
/// destroy and dealloc a block /// destroy and dealloc a block
void free(void *block); void freeBlock(void *block);
// //
uint getNumBytesPerBlock() const { return _NumBytesPerBlock; } uint getNumBytesPerBlock() const { return _NumBytesPerBlock; }
uint getNumBlockPerChunk() const { return _NumBlockPerChunk; } uint getNumBlockPerChunk() const { return _NumBlockPerChunk; }

View file

@ -65,7 +65,7 @@ public:
*/ */
void *allocate(uint size); void *allocate(uint size);
/// free a block allocated with alloate(). no-op if NULL. nlstop() if don't find this block. /// free a block allocated with alloate(). no-op if NULL. nlstop() if don't find this block.
void free(void *ptr); void freeBlock(void *ptr);
// ********************* // *********************

View file

@ -49,7 +49,7 @@ public:
*/ */
void *alloc(uint size); void *alloc(uint size);
// free an object that has previously been allocated with alloc. size should be remembered by the caller. // free an object that has previously been allocated with alloc. size should be remembered by the caller.
void free(void *); void freeBlock(void *);
// get the number of allocated objects // get the number of allocated objects
uint getNumAllocatedBlocks() const; uint getNumAllocatedBlocks() const;
# ifdef NL_DEBUG # ifdef NL_DEBUG

View file

@ -90,7 +90,7 @@ public:
/* /*
* Free all the elements allocated since last free(). Memory is kept for next allocations. * Free all the elements allocated since last free(). Memory is kept for next allocations.
*/ */
void free () void freeBlock ()
{ {
typename std::list< std::vector<T> >::iterator ite=_BlockList.begin(); typename std::list< std::vector<T> >::iterator ite=_BlockList.begin();
while (ite!=_BlockList.end()) while (ite!=_BlockList.end())

View file

@ -1713,9 +1713,9 @@ void CDriverGL::resetVertexArrayRange()
// After, Clear the 2 vertexArrayRange, if any. // After, Clear the 2 vertexArrayRange, if any.
if(_AGPVertexArrayRange) if(_AGPVertexArrayRange)
_AGPVertexArrayRange->free(); _AGPVertexArrayRange->freeBlock();
if(_VRAMVertexArrayRange) if(_VRAMVertexArrayRange)
_VRAMVertexArrayRange->free(); _VRAMVertexArrayRange->freeBlock();
} }

View file

@ -167,7 +167,7 @@ uint CVertexArrayRangeNVidia::sizeAllocated() const
// *************************************************************************** // ***************************************************************************
void CVertexArrayRangeNVidia::free() void CVertexArrayRangeNVidia::freeBlock()
{ {
H_AUTO_OGL(CVertexArrayRangeNVidia_free) H_AUTO_OGL(CVertexArrayRangeNVidia_free)
// release the ptr. // release the ptr.
@ -244,7 +244,7 @@ void *CVertexArrayRangeNVidia::allocateVB(uint32 size)
void CVertexArrayRangeNVidia::freeVB(void *ptr) void CVertexArrayRangeNVidia::freeVB(void *ptr)
{ {
H_AUTO_OGL(CVertexArrayRangeNVidia_freeVB) H_AUTO_OGL(CVertexArrayRangeNVidia_freeVB)
_HeapMemory.free(ptr); _HeapMemory.freeBlock(ptr);
} }
@ -545,7 +545,7 @@ uint CVertexArrayRangeATI::sizeAllocated() const
return _VertexArraySize; return _VertexArraySize;
} }
// *************************************************************************** // ***************************************************************************
void CVertexArrayRangeATI::free() void CVertexArrayRangeATI::freeBlock()
{ {
H_AUTO_OGL(CVertexArrayRangeATI_free) H_AUTO_OGL(CVertexArrayRangeATI_free)
// release the ptr. // release the ptr.
@ -623,7 +623,7 @@ void *CVertexArrayRangeATI::allocateVB(uint32 size)
void CVertexArrayRangeATI::freeVB(void *ptr) void CVertexArrayRangeATI::freeVB(void *ptr)
{ {
H_AUTO_OGL(CVertexArrayRangeATI_freeVB) H_AUTO_OGL(CVertexArrayRangeATI_freeVB)
_HeapMemory.free(ptr); _HeapMemory.freeBlock(ptr);
} }
@ -853,7 +853,7 @@ bool CVertexArrayRangeMapObjectATI::allocate(uint32 size, CVertexBuffer::TPrefer
} }
// *************************************************************************** // ***************************************************************************
void CVertexArrayRangeMapObjectATI::free() void CVertexArrayRangeMapObjectATI::freeBlock()
{ {
H_AUTO_OGL(CVertexArrayRangeMapObjectATI_free) H_AUTO_OGL(CVertexArrayRangeMapObjectATI_free)
_SizeAllocated = 0; _SizeAllocated = 0;
@ -1205,7 +1205,7 @@ bool CVertexArrayRangeARB::allocate(uint32 size, CVertexBuffer::TPreferredMemory
} }
// *************************************************************************** // ***************************************************************************
void CVertexArrayRangeARB::free() void CVertexArrayRangeARB::freeBlock()
{ {
H_AUTO_OGL(CVertexArrayRangeARB_free) H_AUTO_OGL(CVertexArrayRangeARB_free)
_SizeAllocated = 0; _SizeAllocated = 0;

View file

@ -57,7 +57,7 @@ public:
/// allocate a vertex array space. false if error. client must free before re-allocate. /// allocate a vertex array space. false if error. client must free before re-allocate.
virtual bool allocate(uint32 size, CVertexBuffer::TPreferredMemory vbType)= 0; virtual bool allocate(uint32 size, CVertexBuffer::TPreferredMemory vbType)= 0;
/// free this space. /// free this space.
virtual void free()= 0; virtual void freeBlock()= 0;
/// create a IVertexBufferHardGL /// create a IVertexBufferHardGL
virtual IVertexBufferHardGL *createVBHardGL(uint size, CVertexBuffer *vb) =0; virtual IVertexBufferHardGL *createVBHardGL(uint size, CVertexBuffer *vb) =0;
/// return the size allocated. 0 if not allocated or failure /// return the size allocated. 0 if not allocated or failure
@ -141,7 +141,7 @@ public:
/// allocate a vertex array sapce. false if error. must free before re-allocate. /// allocate a vertex array sapce. false if error. must free before re-allocate.
virtual bool allocate(uint32 size, CVertexBuffer::TPreferredMemory vbType); virtual bool allocate(uint32 size, CVertexBuffer::TPreferredMemory vbType);
/// free this space. /// free this space.
virtual void free(); virtual void freeBlock();
/// create a IVertexBufferHardGL /// create a IVertexBufferHardGL
virtual IVertexBufferHardGL *createVBHardGL(uint size, CVertexBuffer *vb); virtual IVertexBufferHardGL *createVBHardGL(uint size, CVertexBuffer *vb);
/// return the size allocated. 0 if not allocated or failure /// return the size allocated. 0 if not allocated or failure
@ -258,7 +258,7 @@ public:
/// allocate a vertex array sapce. false if error. must free before re-allocate. /// allocate a vertex array sapce. false if error. must free before re-allocate.
virtual bool allocate(uint32 size, CVertexBuffer::TPreferredMemory vbType); virtual bool allocate(uint32 size, CVertexBuffer::TPreferredMemory vbType);
/// free this space. /// free this space.
virtual void free(); virtual void freeBlock();
/// create a IVertexBufferHardGL /// create a IVertexBufferHardGL
virtual IVertexBufferHardGL *createVBHardGL(uint size, CVertexBuffer *vb); virtual IVertexBufferHardGL *createVBHardGL(uint size, CVertexBuffer *vb);
/// return the size allocated. 0 if not allocated or failure /// return the size allocated. 0 if not allocated or failure
@ -367,7 +367,7 @@ public:
*/ */
virtual bool allocate(uint32 size, CVertexBuffer::TPreferredMemory vbType); virtual bool allocate(uint32 size, CVertexBuffer::TPreferredMemory vbType);
/// free this space. /// free this space.
virtual void free(); virtual void freeBlock();
/// create a IVertexBufferHardGL /// create a IVertexBufferHardGL
virtual IVertexBufferHardGL *createVBHardGL(uint size, CVertexBuffer *vb); virtual IVertexBufferHardGL *createVBHardGL(uint size, CVertexBuffer *vb);
/// return the size allocated. 0 if not allocated or failure /// return the size allocated. 0 if not allocated or failure
@ -480,7 +480,7 @@ public:
*/ */
virtual bool allocate(uint32 size, CVertexBuffer::TPreferredMemory vbType); virtual bool allocate(uint32 size, CVertexBuffer::TPreferredMemory vbType);
/// free this space. /// free this space.
virtual void free(); virtual void freeBlock();
/// create a IVertexBufferHardGL /// create a IVertexBufferHardGL
virtual IVertexBufferHardGL *createVBHardGL(uint size, CVertexBuffer *vb); virtual IVertexBufferHardGL *createVBHardGL(uint size, CVertexBuffer *vb);
/// return the size allocated. 0 if not allocated or failure /// return the size allocated. 0 if not allocated or failure

View file

@ -3216,37 +3216,37 @@ void CLandscape::deleteTessFace(CTessFace *f)
// for refine() mgt, must remove from refine priority list, or from the temp rootTessFaceToUpdate list. // for refine() mgt, must remove from refine priority list, or from the temp rootTessFaceToUpdate list.
f->unlinkInPList(); f->unlinkInPList();
TessFaceAllocator.free(f); TessFaceAllocator.freeBlock(f);
} }
// *************************************************************************** // ***************************************************************************
void CLandscape::deleteTessVertex(CTessVertex *v) void CLandscape::deleteTessVertex(CTessVertex *v)
{ {
TessVertexAllocator.free(v); TessVertexAllocator.freeBlock(v);
} }
// *************************************************************************** // ***************************************************************************
void CLandscape::deleteTessNearVertex(CTessNearVertex *v) void CLandscape::deleteTessNearVertex(CTessNearVertex *v)
{ {
TessNearVertexAllocator.free(v); TessNearVertexAllocator.freeBlock(v);
} }
// *************************************************************************** // ***************************************************************************
void CLandscape::deleteTessFarVertex(CTessFarVertex *v) void CLandscape::deleteTessFarVertex(CTessFarVertex *v)
{ {
TessFarVertexAllocator.free(v); TessFarVertexAllocator.freeBlock(v);
} }
// *************************************************************************** // ***************************************************************************
void CLandscape::deleteTileMaterial(CTileMaterial *tm) void CLandscape::deleteTileMaterial(CTileMaterial *tm)
{ {
TileMaterialAllocator.free(tm); TileMaterialAllocator.freeBlock(tm);
} }
// *************************************************************************** // ***************************************************************************
void CLandscape::deleteTileFace(CTileFace *tf) void CLandscape::deleteTileFace(CTileFace *tf)
{ {
TileFaceAllocator.free(tf); TileFaceAllocator.freeBlock(tf);
} }

View file

@ -243,7 +243,7 @@ void CTileBank::freeTile (int tileIndex)
nlassert (tileIndex<(sint)_TileVector.size()); nlassert (tileIndex<(sint)_TileVector.size());
// Free // Free
_TileVector[tileIndex].free(); _TileVector[tileIndex].freeBlock();
// Resize tile table // Resize tile table
int i; int i;

View file

@ -750,7 +750,7 @@ void CVegetableManager::deleteClipBlock(CVegetableClipBlock *clipBlock)
_EmptyClipBlockList.remove(clipBlock); _EmptyClipBlockList.remove(clipBlock);
// delete // delete
_ClipBlockMemory.free(clipBlock); _ClipBlockMemory.freeBlock(clipBlock);
} }
@ -785,7 +785,7 @@ void CVegetableManager::deleteSortBlock(CVegetableSortBlock *sortBlock)
sortBlock->_Owner->_SortBlockList.remove(sortBlock); sortBlock->_Owner->_SortBlockList.remove(sortBlock);
// delete // delete
_SortBlockMemory.free(sortBlock); _SortBlockMemory.freeBlock(sortBlock);
} }
@ -881,7 +881,7 @@ void CVegetableManager::deleteIg(CVegetableInstanceGroup *ig)
// unlink from sortBlock, and delete. // unlink from sortBlock, and delete.
sortBlock->_InstanceGroupList.remove(ig); sortBlock->_InstanceGroupList.remove(ig);
_InstanceGroupMemory.free(ig); _InstanceGroupMemory.freeBlock(ig);
// decRef the clipBlock // decRef the clipBlock

View file

@ -98,7 +98,7 @@ CVisualTileDescNode *CVisualCollisionManager::newVisualTileDescNode()
// *************************************************************************** // ***************************************************************************
void CVisualCollisionManager::deleteVisualTileDescNode(CVisualTileDescNode *ptr) void CVisualCollisionManager::deleteVisualTileDescNode(CVisualTileDescNode *ptr)
{ {
_TileDescNodeAllocator.free(ptr); _TileDescNodeAllocator.freeBlock(ptr);
} }
// *************************************************************************** // ***************************************************************************
@ -110,7 +110,7 @@ CPatchQuadBlock *CVisualCollisionManager::newPatchQuadBlock()
// *************************************************************************** // ***************************************************************************
void CVisualCollisionManager::deletePatchQuadBlock(CPatchQuadBlock *ptr) void CVisualCollisionManager::deletePatchQuadBlock(CPatchQuadBlock *ptr)
{ {
_PatchQuadBlockAllocator.free(ptr); _PatchQuadBlockAllocator.freeBlock(ptr);
} }

View file

@ -90,7 +90,7 @@ void *CContiguousBlockAllocator::alloc(uint numBytes)
} }
// ********************************************************************************************************* // *********************************************************************************************************
void CContiguousBlockAllocator::free(void *block, uint numBytes) void CContiguousBlockAllocator::freeBlock(void *block, uint numBytes)
{ {
if (!block) return; if (!block) return;
#ifdef NL_DEBUG #ifdef NL_DEBUG

View file

@ -73,7 +73,7 @@ void *CFixedSizeAllocator::alloc()
#define aligned_offsetof(s, m) ((offsetof(s, m) + (NL_DEFAULT_MEMORY_ALIGNMENT - 1)) & ~(NL_DEFAULT_MEMORY_ALIGNMENT - 1)) #define aligned_offsetof(s, m) ((offsetof(s, m) + (NL_DEFAULT_MEMORY_ALIGNMENT - 1)) & ~(NL_DEFAULT_MEMORY_ALIGNMENT - 1))
// ***************************************************************************************************************** // *****************************************************************************************************************
void CFixedSizeAllocator::free(void *block) void CFixedSizeAllocator::freeBlock(void *block)
{ {
if (!block) return; if (!block) return;
/// get the node from the object /// get the node from the object

View file

@ -165,7 +165,7 @@ void *CHeapMemory::allocate(uint size)
} }
// *************************************************************************** // ***************************************************************************
void CHeapMemory::free(void *ptr) void CHeapMemory::freeBlock(void *ptr)
{ {
if(ptr==NULL) if(ptr==NULL)
return; return;

View file

@ -97,7 +97,7 @@ void *CObjectArenaAllocator::alloc(uint size)
} }
// ***************************************************************************************************************** // *****************************************************************************************************************
void CObjectArenaAllocator::free(void *block) void CObjectArenaAllocator::freeBlock(void *block)
{ {
if (!block) return; if (!block) return;
uint8 *realBlock = (uint8 *) block - NL_DEFAULT_MEMORY_ALIGNMENT; // sizeof(uint); // a uint is used at start of block to give its size uint8 *realBlock = (uint8 *) block - NL_DEFAULT_MEMORY_ALIGNMENT; // sizeof(uint); // a uint is used at start of block to give its size
@ -114,7 +114,7 @@ void CObjectArenaAllocator::free(void *block)
} }
uint entry = ((size + (_Granularity - 1)) / _Granularity); uint entry = ((size + (_Granularity - 1)) / _Granularity);
nlassert(entry < _ObjectSizeToAllocator.size()); nlassert(entry < _ObjectSizeToAllocator.size());
_ObjectSizeToAllocator[entry]->free(realBlock); _ObjectSizeToAllocator[entry]->freeBlock(realBlock);
#ifdef NL_DEBUG #ifdef NL_DEBUG
std::map<void *, uint>::iterator it = _MemBlockToAllocID.find(realBlock); std::map<void *, uint>::iterator it = _MemBlockToAllocID.find(realBlock);
nlassert(it != _MemBlockToAllocID.end()); nlassert(it != _MemBlockToAllocID.end());

View file

@ -1304,8 +1304,8 @@ void CMoveContainer::freeAllOTInfo ()
{ {
H_AUTO (NLPACS_Free_All_OT_Info); H_AUTO (NLPACS_Free_All_OT_Info);
_AllocOTDynamicInfo.free (); _AllocOTDynamicInfo.freeBlock ();
_AllocOTStaticInfo.free (); _AllocOTStaticInfo.freeBlock ();
} }
// *************************************************************************** // ***************************************************************************