Partial revert "Crashfix texture viewer, update"
This reverts commit 85e26c05d1.
This commit is contained in:
@@ -139,7 +139,8 @@ BOOL LLImageBase::sSizeOverride = FALSE;
|
||||
// virtual
|
||||
void LLImageBase::deleteData()
|
||||
{
|
||||
delete[] mData;
|
||||
if(mData)
|
||||
free(mData);//delete[] mData;
|
||||
mData = NULL;
|
||||
mDataSize = 0;
|
||||
}
|
||||
@@ -154,7 +155,7 @@ U8* LLImageBase::allocateData(S32 size)
|
||||
size = mWidth * mHeight * mComponents;
|
||||
if (size <= 0)
|
||||
{
|
||||
llerrs << llformat("LLImageBase::allocateData called with bad dimentions: %dx%dx%d",mWidth,mHeight,mComponents) << llendl;
|
||||
llerrs << llformat("LLImageBase::allocateData called with bad dimensions: %dx%dx%d",mWidth,mHeight,mComponents) << llendl;
|
||||
}
|
||||
}
|
||||
else if (size <= 0 || (size > 4096*4096*16 && sSizeOverride == FALSE))
|
||||
@@ -166,14 +167,17 @@ U8* LLImageBase::allocateData(S32 size)
|
||||
{
|
||||
deleteData(); // virtual
|
||||
mBadBufferAllocation = FALSE ;
|
||||
mData = new U8[size];
|
||||
if (!mData)
|
||||
U8 *data = (U8 *)realloc(mData,sizeof(U8)*size);//new U8[size];
|
||||
if (!data)
|
||||
{
|
||||
if(mData)
|
||||
free(mData);
|
||||
llwarns << "allocate image data: " << size << llendl;
|
||||
size = 0 ;
|
||||
mWidth = mHeight = 0 ;
|
||||
mBadBufferAllocation = TRUE ;
|
||||
}
|
||||
mData = data;
|
||||
mDataSize = size;
|
||||
}
|
||||
|
||||
@@ -184,21 +188,16 @@ U8* LLImageBase::allocateData(S32 size)
|
||||
U8* LLImageBase::reallocateData(S32 size)
|
||||
{
|
||||
LLMemType mt1((LLMemType::EMemType)mMemType);
|
||||
U8 *new_datap = new U8[size];
|
||||
if (!new_datap)
|
||||
U8 *data = (U8 *)realloc(mData,sizeof(U8)*size);
|
||||
if(data)
|
||||
{
|
||||
mData = data;
|
||||
mDataSize = size;
|
||||
}
|
||||
else
|
||||
llwarns << "Out of memory in LLImageBase::reallocateData" << llendl;
|
||||
return 0;
|
||||
}
|
||||
if (mData)
|
||||
{
|
||||
S32 bytes = llmin(mDataSize, size);
|
||||
memcpy(new_datap, mData, bytes); /* Flawfinder: ignore */
|
||||
delete[] mData;
|
||||
}
|
||||
mData = new_datap;
|
||||
mDataSize = size;
|
||||
return mData;
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
const U8* LLImageBase::getData() const
|
||||
@@ -659,6 +658,12 @@ void LLImageRaw::fill( const LLColor4U& color )
|
||||
// Src and dst can be any size. Src and dst can each have 3 or 4 components.
|
||||
void LLImageRaw::copy(LLImageRaw* src)
|
||||
{
|
||||
if (!src)
|
||||
{
|
||||
llwarns << "LLImageRaw::copy called with a null src pointer" << llendl;
|
||||
return;
|
||||
}
|
||||
|
||||
LLImageRaw* dst = this; // Just for clarity.
|
||||
|
||||
llassert( (3 == src->getComponents()) || (4 == src->getComponents()) );
|
||||
@@ -839,6 +844,7 @@ BOOL LLImageRaw::scale( S32 new_width, S32 new_height, BOOL scale_image_data )
|
||||
{
|
||||
// Vertical
|
||||
S32 temp_data_size = old_width * new_height * getComponents();
|
||||
llassert_always(temp_data_size > 0);
|
||||
U8* temp_buffer = new U8[ temp_data_size ];
|
||||
for( S32 col = 0; col < old_width; col++ )
|
||||
{
|
||||
@@ -1500,7 +1506,7 @@ void LLImageFormatted::appendData(U8 *data, S32 size)
|
||||
S32 newsize = cursize + size;
|
||||
reallocateData(newsize);
|
||||
memcpy(getData() + cursize, data, size);
|
||||
delete[] data;
|
||||
delete[] data; //Fixing leak from CommentCacheReadResponder
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,7 +156,6 @@ private:
|
||||
|
||||
public:
|
||||
S16 mMemType; // debug
|
||||
|
||||
static BOOL sSizeOverride;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user