summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXiaohong Bao <bao@lindenlab.com>2011-02-24 19:47:55 -0700
committerXiaohong Bao <bao@lindenlab.com>2011-02-24 19:47:55 -0700
commitfc106df53085f549acdbb2f8149ca75e400532fa (patch)
treef4dfb0150467f41ad1d544161ee6946a53e35ad6
parentae65347e3391be56b8919349a269e0abe52cf656 (diff)
fix the compiling error: "free" is defined and in use globally.
-rw-r--r--indra/llcommon/llmemory.cpp20
-rw-r--r--indra/llcommon/llmemory.h12
-rw-r--r--indra/llimage/llimage.cpp2
-rw-r--r--indra/llrender/llvertexbuffer.cpp12
4 files changed, 24 insertions, 22 deletions
diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp
index 062640f546..49e2cd9ac4 100644
--- a/indra/llcommon/llmemory.cpp
+++ b/indra/llcommon/llmemory.cpp
@@ -572,7 +572,7 @@ void LLPrivateMemoryPool::LLMemoryBlock::init(char* buffer, U32 buffer_size, U32
mSlotSize = slot_size ;
mTotalSlots = buffer_size / mSlotSize ;
- llassert_always(mTotalSlots <= 256) ; //max number is 256
+ llassert_always(buffer_size / mSlotSize <= 256) ; //max number is 256
mAllocatedSlots = 0 ;
@@ -669,7 +669,7 @@ char* LLPrivateMemoryPool::LLMemoryBlock::allocate()
}
//free a slot
-void LLPrivateMemoryPool::LLMemoryBlock::free(void* addr)
+void LLPrivateMemoryPool::LLMemoryBlock::freeMem(void* addr)
{
//bit index
U32 idx = ((U32)addr - (U32)mBuffer - mDummySize * sizeof(U32)) / mSlotSize ;
@@ -850,14 +850,14 @@ char* LLPrivateMemoryPool::LLMemoryChunk::allocate(U32 size)
return p ;
}
-void LLPrivateMemoryPool::LLMemoryChunk::free(void* addr)
+void LLPrivateMemoryPool::LLMemoryChunk::freeMem(void* addr)
{
U32 blk_idx = getPageIndex((U32)addr) ;
LLMemoryBlock* blk = (LLMemoryBlock*)(mMetaBuffer + blk_idx * sizeof(LLMemoryBlock)) ;
blk = blk->mSelf ;
bool was_full = blk->isFull() ;
- blk->free(addr) ;
+ blk->freeMem(addr) ;
mAlloatedSize -= blk->getSlotSize() ;
if(blk->empty())
@@ -1349,7 +1349,7 @@ char* LLPrivateMemoryPool::allocate(U32 size)
return p ;
}
-void LLPrivateMemoryPool::free(void* addr)
+void LLPrivateMemoryPool::freeMem(void* addr)
{
if(!addr)
{
@@ -1366,7 +1366,7 @@ void LLPrivateMemoryPool::free(void* addr)
}
else
{
- chunk->free(addr) ;
+ chunk->freeMem(addr) ;
if(chunk->empty())
{
@@ -1929,7 +1929,7 @@ void LLPrivateMemoryPoolTester::test(U32 min_size, U32 max_size, U32 stride, U32
if(p[i][k])
{
llassert_always(*(U32*)p[i][k] == i && *((U32*)p[i][k] + 1) == k) ;
- sPool->free(p[i][k]) ;
+ sPool->freeMem(p[i][k]) ;
total_allocated_size -= min_size + k * stride ;
p[i][k] = NULL ;
}
@@ -1950,7 +1950,7 @@ void LLPrivateMemoryPoolTester::test(U32 min_size, U32 max_size, U32 stride, U32
if(p[i][j])
{
llassert_always(*(U32*)p[i][j] == i && *((U32*)p[i][j] + 1) == j) ;
- sPool->free(p[i][j]) ;
+ sPool->freeMem(p[i][j]) ;
total_allocated_size -= min_size + j * stride ;
p[i][j] = NULL ;
}
@@ -1984,7 +1984,7 @@ void LLPrivateMemoryPoolTester::testAndTime(U32 size, U32 times)
//de-allocation
for(U32 i = 0 ; i < times; i++)
{
- sPool->free(p[i]) ;
+ sPool->freeMem(p[i]) ;
p[i] = NULL ;
}
llinfos << "time spent using customized memory pool: " << timer.getElapsedTimeF32() << llendl ;
@@ -2019,7 +2019,7 @@ void LLPrivateMemoryPoolTester::correctnessTest()
//edge case
char* p = sPool->allocate(0) ;
- sPool->free(p) ;
+ sPool->freeMem(p) ;
//small sized
// [8 bytes, 2KB), each asks for 256 allocations and deallocations
diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h
index a5dbabec5a..001ff9c123 100644
--- a/indra/llcommon/llmemory.h
+++ b/indra/llcommon/llmemory.h
@@ -132,7 +132,7 @@ public:
void setBuffer(char* buffer, U32 buffer_size) ;
char* allocate() ;
- void free(void* addr) ;
+ void freeMem(void* addr) ;
bool empty() {return !mAllocatedSlots;}
bool isFull() {return mAllocatedSlots == mTotalSlots;}
@@ -180,7 +180,7 @@ public:
bool empty() ;
char* allocate(U32 size) ;
- void free(void* addr) ;
+ void freeMem(void* addr) ;
const char* getBuffer() const {return mBuffer;}
U32 getBufferSize() const {return mBufferSize;}
@@ -236,7 +236,7 @@ private:
public:
char *allocate(U32 size) ;
- void free(void* addr) ;
+ void freeMem(void* addr) ;
void dump() ;
U32 getTotalAllocatedSize() ;
@@ -339,6 +339,7 @@ private:
void test(U32 min_size, U32 max_size, U32 stride, U32 times, bool random_deletion, bool output_statistics) ;
void testAndTime(U32 size, U32 times) ;
+#if 0
public:
void* operator new(size_t size)
{
@@ -346,7 +347,7 @@ public:
}
void operator delete(void* addr)
{
- sPool->free(addr) ;
+ sPool->freeMem(addr) ;
}
void* operator new[](size_t size)
{
@@ -354,8 +355,9 @@ public:
}
void operator delete[](void* addr)
{
- sPool->free(addr) ;
+ sPool->freeMem(addr) ;
}
+#endif
private:
static LLPrivateMemoryPoolTester* sInstance;
diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp
index 9298716022..eefcf0a9fb 100644
--- a/indra/llimage/llimage.cpp
+++ b/indra/llimage/llimage.cpp
@@ -140,7 +140,7 @@ void LLImageBase::deleteMemory(void* p)
{
if(sPrivatePoolp)
{
- sPrivatePoolp->free(p) ;
+ sPrivatePoolp->freeMem(p) ;
}
else
{
diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp
index 6b1fd78733..fd2a04373b 100644
--- a/indra/llrender/llvertexbuffer.cpp
+++ b/indra/llrender/llvertexbuffer.cpp
@@ -598,7 +598,7 @@ void LLVertexBuffer::destroyGLBuffer()
}
else
{
- sPrivatePoolp->free(mMappedData) ;
+ sPrivatePoolp->freeMem(mMappedData) ;
mMappedData = NULL;
mEmpty = TRUE;
}
@@ -627,7 +627,7 @@ void LLVertexBuffer::destroyGLIndices()
}
else
{
- sPrivatePoolp->free(mMappedIndexData) ;
+ sPrivatePoolp->freeMem(mMappedIndexData) ;
mMappedIndexData = NULL;
mEmpty = TRUE;
}
@@ -768,7 +768,7 @@ void LLVertexBuffer::resizeBuffer(S32 newnverts, S32 newnindices)
memset(mMappedData+oldsize, 0, newsize-oldsize);
}
- sPrivatePoolp->free(old);
+ sPrivatePoolp->freeMem(old);
}
else
{
@@ -805,7 +805,7 @@ void LLVertexBuffer::resizeBuffer(S32 newnverts, S32 newnindices)
{
memset(mMappedIndexData+old_index_size, 0, new_index_size - old_index_size);
}
- sPrivatePoolp->free(old);
+ sPrivatePoolp->freeMem(old);
}
else
{
@@ -852,8 +852,8 @@ void LLVertexBuffer::freeClientBuffer()
{
if(useVBOs() && sDisableVBOMapping && (mMappedData || mMappedIndexData))
{
- sPrivatePoolp->free(mMappedData) ;
- sPrivatePoolp->free(mMappedIndexData) ;
+ sPrivatePoolp->freeMem(mMappedData) ;
+ sPrivatePoolp->freeMem(mMappedIndexData) ;
mMappedData = NULL ;
mMappedIndexData = NULL ;
}