Fixed two huge memory leaks.

Next time i'll sleep before programming. :P
This commit is contained in:
spartanj
2010-07-13 02:45:29 -03:00
parent 8e197828a8
commit 5dbb935102
9 changed files with 49 additions and 45 deletions
-2
View File
@@ -1,5 +1,3 @@
export DEBUGBUILD=yes
ifeq ($(DEBUGBUILD), yes)
DEBUGFLAGS = -g -DDEBUG -DEE_DEBUG
else
+1 -1
View File
@@ -27,6 +27,6 @@ using namespace EE::System;
#include "renders.hpp"
#define ALLOC_VECTORS
//#define ALLOC_VECTORS
#endif
+20 -20
View File
@@ -5,6 +5,10 @@
namespace EE { namespace Graphics {
cShape::cShape() :
#ifndef ALLOC_VECTORS
mPixels(NULL),
mAlpha(NULL),
#endif
mId(0),
mTexId(0),
mTexture(NULL),
@@ -14,14 +18,14 @@ cShape::cShape() :
mOffSetX(0),
mOffSetY(0)
{
#ifndef ALLOC_VECTORS
mPixels = NULL;
mAlpha = NULL;
#endif
CreateUnnamed();
}
cShape::cShape( const Uint32& TexId, const std::string& Name ) :
#ifndef ALLOC_VECTORS
mPixels(NULL),
mAlpha(NULL),
#endif
mName( Name ),
mId( MakeHash( mName ) ),
mTexId( TexId ),
@@ -32,13 +36,13 @@ cShape::cShape( const Uint32& TexId, const std::string& Name ) :
mOffSetX(0),
mOffSetY(0)
{
#ifndef ALLOC_VECTORS
mPixels = NULL;
mAlpha = NULL;
#endif
}
cShape::cShape( const Uint32& TexId, const eeRecti& SrcRect, const std::string& Name ) :
#ifndef ALLOC_VECTORS
mPixels(NULL),
mAlpha(NULL),
#endif
mName( Name ),
mId( MakeHash( mName ) ),
mTexId( TexId ),
@@ -49,13 +53,13 @@ cShape::cShape( const Uint32& TexId, const eeRecti& SrcRect, const std::string&
mOffSetX(0),
mOffSetY(0)
{
#ifndef ALLOC_VECTORS
mPixels = NULL;
mAlpha = NULL;
#endif
}
cShape::cShape( const Uint32& TexId, const eeRecti& SrcRect, const eeFloat& DestWidth, const eeFloat& DestHeight, const std::string& Name ) :
#ifndef ALLOC_VECTORS
mPixels(NULL),
mAlpha(NULL),
#endif
mName( Name ),
mId( MakeHash( mName ) ),
mTexId( TexId ),
@@ -66,13 +70,13 @@ cShape::cShape( const Uint32& TexId, const eeRecti& SrcRect, const eeFloat& Dest
mOffSetX(0),
mOffSetY(0)
{
#ifndef ALLOC_VECTORS
mPixels = NULL;
mAlpha = NULL;
#endif
}
cShape::cShape( const Uint32& TexId, const eeRecti& SrcRect, const eeFloat& DestWidth, const eeFloat& DestHeight, const eeFloat& OffsetX, const eeFloat& OffsetY, const std::string& Name ) :
#ifndef ALLOC_VECTORS
mPixels(NULL),
mAlpha(NULL),
#endif
mName( Name ),
mId( MakeHash( mName ) ),
mTexId( TexId ),
@@ -83,10 +87,6 @@ cShape::cShape( const Uint32& TexId, const eeRecti& SrcRect, const eeFloat& Dest
mOffSetX(OffsetX),
mOffSetY(OffsetY)
{
#ifndef ALLOC_VECTORS
mPixels = NULL;
mAlpha = NULL;
#endif
}
cShape::~cShape() {
+8 -8
View File
@@ -87,6 +87,14 @@ class EE_API cShape {
bool SaveToFile(const std::string& filepath, const EE_SAVETYPE& Format);
protected:
#ifndef ALLOC_VECTORS
eeColorA * mPixels;
Uint8 * mAlpha;
#else
std::vector<eeColorA> mPixels;
std::vector<Uint8> mAlpha;
#endif
std::string mName;
Uint32 mId;
Uint32 mTexId;
@@ -97,14 +105,6 @@ class EE_API cShape {
eeFloat mOffSetX;
eeFloat mOffSetY;
#ifndef ALLOC_VECTORS
eeColorA * mPixels;
Uint8 * mAlpha;
#else
std::vector<eeColorA> mPixels;
std::vector<Uint8> mAlpha;
#endif
void CreateUnnamed();
};
+3 -3
View File
@@ -4,6 +4,9 @@
namespace EE { namespace Graphics {
cTexture::cTexture() :
#ifndef ALLOC_VECTORS
mPixels(NULL),
#endif
mFilepath(""),
mId(0),
mTexture(0),
@@ -21,9 +24,6 @@ cTexture::cTexture() :
mLocked(false),
mGrabed(false)
{
#ifndef ALLOC_VECTORS
mPixels = NULL;
#endif
}
cTexture::cTexture( const cTexture& Copy ) :
+6 -6
View File
@@ -216,6 +216,12 @@ class EE_API cTexture {
/** @return The texture factory internal id of the texture */
const Uint32& TexId() const;
protected:
#ifndef ALLOC_VECTORS
eeColorA * mPixels;
#else
std::vector<eeColorA> mPixels;
#endif
std::string mFilepath;
Uint32 mId;
@@ -240,12 +246,6 @@ class EE_API cTexture {
bool mLocked;
bool mGrabed;
#ifndef ALLOC_VECTORS
eeColorA * mPixels;
#else
std::vector<eeColorA> mPixels;
#endif
void ApplyClampMode();
void Allocate( const Uint32& size );
};
+7 -3
View File
@@ -82,9 +82,13 @@ Uint32 cTextureFactory::LoadFromMemory( const unsigned char* Surface, const eeUi
unsigned char * PixelsPtr = SOIL_load_image_from_memory(Surface, Size, &ImgWidth, &ImgHeight, &ImgChannels, SOIL_LOAD_AUTO);
if ( NULL != PixelsPtr )
return LoadFromPixels( PixelsPtr, ImgWidth, ImgHeight, ImgChannels, mipmap, ColorKey, ClampMode, CompressTexture, KeepLocalCopy );
else
if ( NULL != PixelsPtr ) {
Uint32 Result = LoadFromPixels( PixelsPtr, ImgWidth, ImgHeight, ImgChannels, mipmap, ColorKey, ClampMode, CompressTexture, KeepLocalCopy );
SOIL_free_image_data( PixelsPtr );
return Result;
} else
Log->Write( SOIL_last_result() );
return 0;
+1
View File
@@ -41,6 +41,7 @@ namespace HaikuTTF {
#define hkARRAY_SIZE(__array) ( sizeof(__array) / sizeof(__array[0]) )
#define hkSAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } }
#define hkSAFE_FREE(p) { if(p) { free (p); (p)=NULL; } }
#define hkSAFE_DELETE_ARRAY(p) { if(p) { delete[](p); (p)=NULL; } }
#define HK_GETSET( __TYPE, __NAME ) \
+3 -2
View File
@@ -18,14 +18,15 @@ hkGlyph::hkGlyph() :
}
hkGlyph::~hkGlyph() {
Flush();
}
void hkGlyph::Flush() {
mStored = 0;
mIndex = 0;
hkSAFE_DELETE_ARRAY( mBitmap.buffer );
//hkSAFE_DELETE_ARRAY( mPixmap.buffer );
hkSAFE_FREE( mBitmap.buffer );
hkSAFE_FREE( mPixmap.buffer );
mCached = 0;
}