Fixed memory leak in FTGL associated with the function of gluTesselate.

Fixed a warnings in the DW plugin.
This commit is contained in:
Robert Osfield
2002-04-18 09:57:42 +00:00
parent 791150ab69
commit ab64566b61
2 changed files with 18 additions and 1 deletions

View File

@@ -407,7 +407,7 @@ public:
GLfloat w[4], avertex **dataOut , _dwobj *dwob);
void linkholes(const std::vector<Vec3> verts, const dwmaterial *themat,
const _face *f1, const _face *f2,
const int ipr[2], const int idx[], const int nv) {
const int ipr[2], const int /*idx*/[], const int nv) {
gsidx[nload]=f1->getidx(ipr[1]); // vertex position index
gsidx[nload+1]=f1->getidx(ipr[0]); // vertex position index
gsidx[nload+2]=f2->getidx(nv-ipr[0]-1); // vertex position index

View File

@@ -33,10 +33,18 @@ void CALLBACK ftglEnd()
}
// this static vector is to keep track of memory allocated by the combine
// callback below, so that it can be later deleted. This approach does
// assume that the Tesselate method is single threaded.
typedef std::vector<double*> CreatedVertices;
static CreatedVertices s_createdVertices;
void CALLBACK ftglCombine( GLdouble coords[3], void* /*vertex_data*/[4], GLfloat /*weight*/[4], void** outData)
{
double* vertex = osgNew double[3]; // FIXME MEM LEAK
s_createdVertices.push_back(vertex);
vertex[0] = coords[0];
vertex[1] = coords[1];
vertex[2] = coords[2];
@@ -130,6 +138,15 @@ void FTPolyGlyph::Tesselate()
glEndList();
gluDeleteTess( tobj);
// clean up the vertices create in the combine callback.
for(CreatedVertices::iterator itr=s_createdVertices.begin();
itr!=s_createdVertices.end();
++itr)
{
osgDelete [] (*itr);
}
s_createdVertices.clear();
}