diff options
author | Xiaohong Bao <bao@lindenlab.com> | 2011-05-10 21:02:20 -0600 |
---|---|---|
committer | Xiaohong Bao <bao@lindenlab.com> | 2011-05-10 21:02:20 -0600 |
commit | b594d3b04d3095f15750436910debdd5a602a872 (patch) | |
tree | b8c4456373a93d06d5dabc80416170bda1ad71b1 /indra/llimage | |
parent | 1213e5d3548a111a39b6556c6178fc4bc655d367 (diff) |
add debug mode to track the memory allocation/deallocation.
Diffstat (limited to 'indra/llimage')
-rw-r--r-- | indra/llimage/llimage.cpp | 36 | ||||
-rw-r--r-- | indra/llimage/llimage.h | 3 | ||||
-rw-r--r-- | indra/llimage/llimagedxt.cpp | 2 | ||||
-rw-r--r-- | indra/llimage/llimagej2c.cpp | 4 |
4 files changed, 9 insertions, 36 deletions
diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp index eefcf0a9fb..cfa4123b1e 100644 --- a/indra/llimage/llimage.cpp +++ b/indra/llimage/llimage.cpp @@ -122,32 +122,6 @@ void LLImageBase::destroyPrivatePool() } } -//static -char* LLImageBase::allocateMemory(S32 size) -{ - if(sPrivatePoolp) - { - return sPrivatePoolp->allocate(size) ; - } - else - { - return new char[size]; - } -} - -//static -void LLImageBase::deleteMemory(void* p) -{ - if(sPrivatePoolp) - { - sPrivatePoolp->freeMem(p) ; - } - else - { - delete[] (char*)p ; - } -} - // virtual void LLImageBase::dump() { @@ -181,7 +155,7 @@ void LLImageBase::sanityCheck() // virtual void LLImageBase::deleteData() { - deleteMemory(mData) ; + FREE_MEM(sPrivatePoolp, mData) ; mData = NULL; mDataSize = 0; } @@ -218,7 +192,7 @@ U8* LLImageBase::allocateData(S32 size) { deleteData(); // virtual mBadBufferAllocation = false ; - mData = (U8*)allocateMemory(size); + mData = (U8*)ALLOCATE_MEM(sPrivatePoolp, size); if (!mData) { llwarns << "allocate image data: " << size << llendl; @@ -236,7 +210,7 @@ U8* LLImageBase::allocateData(S32 size) U8* LLImageBase::reallocateData(S32 size) { LLMemType mt1(mMemType); - U8 *new_datap = (U8*)allocateMemory(size); + U8 *new_datap = (U8*)ALLOCATE_MEM(sPrivatePoolp, size); if (!new_datap) { llwarns << "Out of memory in LLImageBase::reallocateData" << llendl; @@ -246,7 +220,7 @@ U8* LLImageBase::reallocateData(S32 size) { S32 bytes = llmin(mDataSize, size); memcpy(new_datap, mData, bytes); /* Flawfinder: ignore */ - deleteMemory(mData) ; + FREE_MEM(sPrivatePoolp, mData) ; } mData = new_datap; mDataSize = size; @@ -1601,7 +1575,7 @@ void LLImageFormatted::appendData(U8 *data, S32 size) S32 newsize = cursize + size; reallocateData(newsize); memcpy(getData() + cursize, data, size); - deleteMemory(data); + FREE_MEM(LLImageBase::getPrivatePool(), data); } } } diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h index ab20ccda9e..10621623ad 100644 --- a/indra/llimage/llimage.h +++ b/indra/llimage/llimage.h @@ -140,8 +140,7 @@ public: static void createPrivatePool() ; static void destroyPrivatePool() ; - static char* allocateMemory(S32 size) ; - static void deleteMemory(void* p) ; + static LLPrivateMemoryPool* getPrivatePool() {return sPrivatePoolp;} private: U8 *mData; diff --git a/indra/llimage/llimagedxt.cpp b/indra/llimage/llimagedxt.cpp index 81be09a412..2867f5e6f0 100644 --- a/indra/llimage/llimagedxt.cpp +++ b/indra/llimage/llimagedxt.cpp @@ -429,7 +429,7 @@ bool LLImageDXT::convertToDXR() S32 nmips = calcNumMips(width,height); S32 total_bytes = getDataSize(); U8* olddata = getData(); - U8* newdata = (U8*)allocateMemory(total_bytes); + U8* newdata = (U8*)ALLOCATE_MEM(LLImageBase::getPrivatePool(), total_bytes); if (!newdata) { llerrs << "Out of memory in LLImageDXT::convertToDXR()" << llendl; diff --git a/indra/llimage/llimagej2c.cpp b/indra/llimage/llimagej2c.cpp index 1bdcba6eb5..78e5d58f14 100644 --- a/indra/llimage/llimagej2c.cpp +++ b/indra/llimage/llimagej2c.cpp @@ -372,14 +372,14 @@ BOOL LLImageJ2C::loadAndValidate(const std::string &filename) } else { - U8 *data = (U8*)allocateMemory(file_size); + U8 *data = (U8*)ALLOCATE_MEM(LLImageBase::getPrivatePool(), file_size); apr_size_t bytes_read = file_size; apr_status_t s = apr_file_read(apr_file, data, &bytes_read); // modifies bytes_read infile.close() ; if (s != APR_SUCCESS || (S32)bytes_read != file_size) { - deleteMemory(data); + FREE_MEM(LLImageBase::getPrivatePool(), data); setLastError("Unable to read entire file"); res = FALSE; } |