Added support for osg::MemoryManager which is based upon Paul Nettle's
memory manager published at flipcode.com. This can be turned on with the OSG_USE_MEMORY_MANGER option which then uses custom global new and delete operators as well as provide osgNew and osgDelete macro's which add ability to log line and file from which calls are made. Updated osg,osgUtil,osgDB,osgText and osgPlugins/osg to use osgNew/osgDelete, and fixed memory leaks highlighted by the new memory manager.
This commit is contained in:
@@ -31,7 +31,7 @@ FTBitmapGlyph::FTBitmapGlyph( FT_Glyph glyph)
|
||||
destWidth = srcWidth;
|
||||
destHeight = srcHeight;
|
||||
|
||||
data = new unsigned char[srcPitch * destHeight];
|
||||
data = osgNew unsigned char[srcPitch * destHeight];
|
||||
|
||||
for(int y = 0; y < srcHeight; ++y)
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@ FTFace::FTFace()
|
||||
|
||||
FTFace::~FTFace()
|
||||
{
|
||||
delete charMap;
|
||||
osgDelete charMap;
|
||||
charMap = 0;
|
||||
Close();
|
||||
}
|
||||
@@ -23,18 +23,18 @@ FTFace::~FTFace()
|
||||
|
||||
bool FTFace::Open( const char* filename)
|
||||
{
|
||||
ftFace = new FT_Face;
|
||||
ftFace = osgNew FT_Face;
|
||||
err = FT_New_Face( *FTLibrary::Instance().GetLibrary(), filename, 0, ftFace);
|
||||
|
||||
if( err)
|
||||
{
|
||||
delete ftFace;
|
||||
osgDelete ftFace;
|
||||
ftFace = 0;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
charMap = new FTCharmap( *ftFace);
|
||||
charMap = osgNew FTCharmap( *ftFace);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,7 @@ void FTFace::Close()
|
||||
if( ftFace)
|
||||
{
|
||||
FT_Done_Face( *ftFace);
|
||||
delete ftFace;
|
||||
osgDelete ftFace;
|
||||
ftFace = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,8 +44,8 @@ bool FTFont::Open( const char* fontname )
|
||||
void FTFont::Close()
|
||||
{
|
||||
GlyphContextContainer::iterator itr;
|
||||
for(itr=_contextGlyphList.begin();itr<_contextGlyphList.begin();itr++)
|
||||
delete *itr;
|
||||
for(itr=_contextGlyphList.begin();itr!=_contextGlyphList.end();itr++)
|
||||
osgDelete *itr;
|
||||
_contextGlyphList.clear();
|
||||
}
|
||||
|
||||
@@ -61,9 +61,9 @@ bool FTFont::FaceSize( const unsigned int size, const unsigned int res , unsigne
|
||||
FTGlyphContainer*& glyphList=_contextGlyphList[renderContext];
|
||||
|
||||
if( glyphList)
|
||||
delete glyphList;
|
||||
osgDelete glyphList;
|
||||
|
||||
glyphList = new FTGlyphContainer( &face, numGlyphs);
|
||||
glyphList = osgNew FTGlyphContainer( &face, numGlyphs);
|
||||
|
||||
if( MakeGlyphList(renderContext))
|
||||
{
|
||||
|
||||
@@ -98,5 +98,7 @@
|
||||
# define FTGL_EXPORT
|
||||
#endif
|
||||
|
||||
#include <osg/MemoryManager>
|
||||
|
||||
|
||||
#endif // __FTGL__
|
||||
|
||||
@@ -25,7 +25,7 @@ bool FTGLBitmapFont::MakeGlyphList(unsigned int renderContext)
|
||||
|
||||
if( ftGlyph)
|
||||
{
|
||||
FTBitmapGlyph* tempGlyph = new FTBitmapGlyph( *ftGlyph);
|
||||
FTBitmapGlyph* tempGlyph = osgNew FTBitmapGlyph( *ftGlyph);
|
||||
glyphList->Add( tempGlyph);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -23,7 +23,7 @@ bool FTGLOutlineFont::MakeGlyphList( unsigned int renderContext)
|
||||
|
||||
if( ftGlyph)
|
||||
{
|
||||
FTOutlineGlyph* tempGlyph = new FTOutlineGlyph( *ftGlyph);
|
||||
FTOutlineGlyph* tempGlyph = osgNew FTOutlineGlyph( *ftGlyph);
|
||||
glyphList->Add( tempGlyph);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -25,7 +25,7 @@ bool FTGLPixmapFont::MakeGlyphList(unsigned int renderContext)
|
||||
|
||||
if( ftGlyph)
|
||||
{
|
||||
FTPixmapGlyph* tempGlyph = new FTPixmapGlyph( *ftGlyph);
|
||||
FTPixmapGlyph* tempGlyph = osgNew FTPixmapGlyph( *ftGlyph);
|
||||
glyphList->Add( tempGlyph);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -24,7 +24,7 @@ bool FTGLPolygonFont::MakeGlyphList( unsigned int renderContext)
|
||||
|
||||
if( ftGlyph)
|
||||
{
|
||||
FTPolyGlyph* tempGlyph = new FTPolyGlyph( *ftGlyph);
|
||||
FTPolyGlyph* tempGlyph = osgNew FTPolyGlyph( *ftGlyph);
|
||||
glyphList->Add( tempGlyph);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -50,7 +50,7 @@ FTGLTextureFont::~FTGLTextureFont()
|
||||
for(itr=glContextTextureID.begin();itr != glContextTextureID.end(); itr++)
|
||||
{
|
||||
glDeleteTextures( numTextures, (const GLuint*)*itr);
|
||||
delete *itr;
|
||||
osgDelete [] *itr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ bool FTGLTextureFont::MakeGlyphList(unsigned int renderContext)
|
||||
|
||||
glGenTextures( numTextures, (GLuint*)&glTextureID[0]);
|
||||
|
||||
textMem = new unsigned char[totalMem]; // GL_ALPHA texture;
|
||||
textMem = osgNew unsigned char[totalMem]; // GL_ALPHA texture;
|
||||
memset( textMem, 0, totalMem);
|
||||
|
||||
unsigned int glyphNum = 0;
|
||||
@@ -120,14 +120,14 @@ bool FTGLTextureFont::MakeGlyphList(unsigned int renderContext)
|
||||
|
||||
glGenTextures( numTextures, (GLuint*)&glTextureID[0]);
|
||||
|
||||
textMem = new unsigned char[totalMem]; // GL_ALPHA texture;
|
||||
textMem = osgNew unsigned char[totalMem]; // GL_ALPHA texture;
|
||||
memset( textMem, 0, totalMem);
|
||||
|
||||
FillGlyphs( 0, glTextureID[0], textureWidth, textureHeight, textMem,renderContext);
|
||||
CreateTexture( glTextureID[0], textureWidth, textureHeight, textMem);
|
||||
}
|
||||
|
||||
delete [] textMem;
|
||||
osgDelete [] textMem;
|
||||
return !err;
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ unsigned int FTGLTextureFont::FillGlyphs( unsigned int glyphStart, GLuint id, GL
|
||||
|
||||
currTextU = (float)currentTextX / (float)width;
|
||||
|
||||
FTTextureGlyph* tempGlyph = new FTTextureGlyph( *ftGlyph, id, data, width, height, currTextU, currTextV);
|
||||
FTTextureGlyph* tempGlyph = osgNew FTTextureGlyph( *ftGlyph, id, data, width, height, currTextU, currTextV);
|
||||
glyphList->Add( tempGlyph);
|
||||
|
||||
currentTextX += glyphWidth;
|
||||
|
||||
@@ -19,7 +19,7 @@ FTGlyphContainer::~FTGlyphContainer()
|
||||
vector<FTGlyph*>::iterator iter;
|
||||
for( iter = glyphs.begin(); iter != glyphs.end(); ++iter)
|
||||
{
|
||||
delete *iter;
|
||||
osgDelete *iter;
|
||||
}
|
||||
|
||||
glyphs.clear();
|
||||
|
||||
@@ -14,7 +14,7 @@ FTLibrary::~FTLibrary()
|
||||
{
|
||||
FT_Done_FreeType( *lib);
|
||||
|
||||
delete lib;
|
||||
osgDelete lib;
|
||||
lib= 0;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ FTLibrary::~FTLibrary()
|
||||
// {
|
||||
// FTC_Manager_Done( manager );
|
||||
//
|
||||
// delete manager;
|
||||
// osgDelete manager;
|
||||
// manager= 0;
|
||||
// }
|
||||
}
|
||||
@@ -41,12 +41,12 @@ bool FTLibrary::Init()
|
||||
if( lib != 0 )
|
||||
return true;
|
||||
|
||||
lib = new FT_Library;
|
||||
lib = osgNew FT_Library;
|
||||
|
||||
err = FT_Init_FreeType( lib);
|
||||
if( err)
|
||||
{
|
||||
delete lib;
|
||||
osgDelete lib;
|
||||
lib = 0;
|
||||
return false;
|
||||
}
|
||||
@@ -55,7 +55,7 @@ bool FTLibrary::Init()
|
||||
//
|
||||
// if( FTC_Manager_New( lib, 0, 0, 0, my_face_requester, 0, manager )
|
||||
// {
|
||||
// delete manager;
|
||||
// osgDelete manager;
|
||||
// manager= 0;
|
||||
// return false;
|
||||
// }
|
||||
|
||||
@@ -18,11 +18,11 @@ FTOutlineGlyph::FTOutlineGlyph( FT_Glyph glyph)
|
||||
return;
|
||||
}
|
||||
|
||||
vectoriser = new FTVectoriser( glyph);
|
||||
vectoriser = osgNew FTVectoriser( glyph);
|
||||
|
||||
vectoriser->Process();
|
||||
numContours = vectoriser->contours();
|
||||
contourLength = new int[ numContours];
|
||||
contourLength = osgNew int[ numContours];
|
||||
|
||||
for( int cn = 0; cn < numContours; ++cn)
|
||||
{
|
||||
@@ -30,12 +30,12 @@ FTOutlineGlyph::FTOutlineGlyph( FT_Glyph glyph)
|
||||
}
|
||||
|
||||
numPoints = vectoriser->points();
|
||||
data = new double[ numPoints * 3];
|
||||
data = osgNew double[ numPoints * 3];
|
||||
vectoriser->MakeOutline( data);
|
||||
|
||||
advance = glyph->advance.x >> 16;
|
||||
|
||||
delete vectoriser;
|
||||
osgDelete vectoriser;
|
||||
|
||||
if ( ( numContours < 1) || ( numPoints < 3))
|
||||
return;
|
||||
@@ -63,8 +63,8 @@ FTOutlineGlyph::FTOutlineGlyph( FT_Glyph glyph)
|
||||
|
||||
FTOutlineGlyph::~FTOutlineGlyph()
|
||||
{
|
||||
delete [] data;
|
||||
delete [] contourLength;
|
||||
osgDelete [] data;
|
||||
osgDelete [] contourLength;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ FTPixmapGlyph::FTPixmapGlyph( FT_Glyph glyph)
|
||||
destWidth = srcWidth;
|
||||
destHeight = srcHeight;
|
||||
|
||||
data = new unsigned char[destWidth * destHeight * 4];
|
||||
data = osgNew unsigned char[destWidth * destHeight * 4];
|
||||
|
||||
// Get the current glColor.
|
||||
float ftglColour[4];
|
||||
|
||||
@@ -35,8 +35,8 @@ void CALLBACK ftglEnd()
|
||||
|
||||
void CALLBACK ftglCombine( GLdouble coords[3], void* vertex_data[4], GLfloat weight[4], void** outData)
|
||||
{
|
||||
double* vertex = new double[3]; // FIXME MEM LEAK
|
||||
|
||||
double* vertex = osgNew double[3]; // FIXME MEM LEAK
|
||||
|
||||
vertex[0] = coords[0];
|
||||
vertex[1] = coords[1];
|
||||
vertex[2] = coords[2];
|
||||
@@ -57,11 +57,11 @@ FTPolyGlyph::FTPolyGlyph( FT_Glyph glyph)
|
||||
if( ft_glyph_format_outline != glyph->format)
|
||||
{ return;}
|
||||
|
||||
vectoriser = new FTVectoriser( glyph);
|
||||
vectoriser = osgNew FTVectoriser( glyph);
|
||||
|
||||
vectoriser->Process();
|
||||
numContours = vectoriser->contours();
|
||||
contourLength = new int[ numContours];
|
||||
contourLength = osgNew int[ numContours];
|
||||
|
||||
for( int c = 0; c < numContours; ++c)
|
||||
{
|
||||
@@ -69,14 +69,14 @@ FTPolyGlyph::FTPolyGlyph( FT_Glyph glyph)
|
||||
}
|
||||
|
||||
numPoints = vectoriser->points();
|
||||
data = new double[ numPoints * 3];
|
||||
data = osgNew double[ numPoints * 3];
|
||||
// FIXME MakeMesh
|
||||
vectoriser->MakeOutline( data);
|
||||
|
||||
contourFlag = vectoriser->ContourFlag();
|
||||
advance = glyph->advance.x >> 16;
|
||||
|
||||
delete vectoriser;
|
||||
osgDelete vectoriser;
|
||||
|
||||
if ( ( numContours < 1) || ( numPoints < 3))
|
||||
return;
|
||||
@@ -135,8 +135,8 @@ void FTPolyGlyph::Tesselate()
|
||||
|
||||
FTPolyGlyph::~FTPolyGlyph()
|
||||
{
|
||||
delete [] data;
|
||||
delete [] contourLength;
|
||||
osgDelete [] data;
|
||||
osgDelete [] contourLength;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ FTVectoriser::~FTVectoriser()
|
||||
{
|
||||
for( int c = 0; c < contours(); ++c)
|
||||
{
|
||||
delete contourList[c];
|
||||
osgDelete contourList[c];
|
||||
}
|
||||
|
||||
contourList.clear();
|
||||
@@ -70,7 +70,7 @@ bool FTVectoriser::Process()
|
||||
|
||||
for( short c = 0; c < cont; ++c)
|
||||
{
|
||||
contour = new FTContour;
|
||||
contour = osgNew FTContour;
|
||||
contourFlag = ftOutline.flags;
|
||||
last = ftOutline.contours[c];
|
||||
|
||||
|
||||
@@ -157,7 +157,7 @@ void Font::clear()
|
||||
|
||||
if(_font)
|
||||
{
|
||||
delete _font;
|
||||
osgDelete _font;
|
||||
_font=NULL;
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ RasterFont()
|
||||
FTFont* BitmapFont::
|
||||
createFontObj(void)
|
||||
{
|
||||
return (FTFont*)(new FTGLBitmapFont);
|
||||
return (FTFont*)(osgNew FTGLBitmapFont);
|
||||
}
|
||||
|
||||
// BitmapFont
|
||||
@@ -245,7 +245,7 @@ RasterFont(font)
|
||||
FTFont* PixmapFont::
|
||||
createFontObj(void)
|
||||
{
|
||||
return (FTFont*)(new FTGLPixmapFont);
|
||||
return (FTFont*)(osgNew FTGLPixmapFont);
|
||||
}
|
||||
|
||||
// PixmapFont
|
||||
@@ -285,7 +285,7 @@ RasterFont(font)
|
||||
FTFont* TextureFont::
|
||||
createFontObj(void)
|
||||
{
|
||||
return (FTFont*)(new FTGLTextureFont(_textureSize));
|
||||
return (FTFont*)(osgNew FTGLTextureFont(_textureSize));
|
||||
}
|
||||
|
||||
// TextureFont
|
||||
@@ -311,7 +311,7 @@ VectorFont(font)
|
||||
FTFont* OutlineFont::
|
||||
createFontObj(void)
|
||||
{
|
||||
return (FTFont*)(new FTGLOutlineFont);
|
||||
return (FTFont*)(osgNew FTGLOutlineFont);
|
||||
}
|
||||
|
||||
// _FTGLOutlineFont
|
||||
@@ -349,7 +349,7 @@ VectorFont(std::string(font))
|
||||
FTFont* PolygonFont::
|
||||
createFontObj(void)
|
||||
{
|
||||
return (FTFont*)(new FTGLPolygonFont);
|
||||
return (FTFont*)(osgNew FTGLPolygonFont);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ void Paragraph::createDrawables()
|
||||
++itr)
|
||||
{
|
||||
|
||||
osgText::Text* textDrawable = new osgText::Text(_font.get());
|
||||
osgText::Text* textDrawable = osgNew osgText::Text(_font.get());
|
||||
textDrawable->setAlignment(_alignment);
|
||||
textDrawable->setPosition(pos);
|
||||
textDrawable->setText(*itr);
|
||||
|
||||
Reference in New Issue
Block a user