From 8eb351d72269eb140704d7f764ea3c35152a9bb7 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 21 Nov 2008 11:52:48 +0000 Subject: [PATCH] From Gordon Tomlinson, "Find enclosed fix for a leak in the Tessellator::reset(), were the new verts were not being deleted, only the container was We have confirmed the leak while running things through Purify," Small code tweaks by Robert Osfield to streamline the code. --- src/osgUtil/Tessellator.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/osgUtil/Tessellator.cpp b/src/osgUtil/Tessellator.cpp index 8335c9a41..38e76e561 100644 --- a/src/osgUtil/Tessellator.cpp +++ b/src/osgUtil/Tessellator.cpp @@ -103,15 +103,27 @@ void Tessellator::reset() gluDeleteTess(_tobj); _tobj = 0; } - for (Vec3dList::iterator i = _coordData.begin(); i != _coordData.end(); ++i) { - delete (*i); + + for (Vec3dList::iterator i = _coordData.begin(); i != _coordData.end(); ++i) + { + delete (*i); } + + // We need to also free the vertex list as well otherwise we are leaking... + for (NewVertexList::iterator j = _newVertexList.begin(); j != _newVertexList.end(); ++j) + { + NewVertex& newVertex = (*j); + delete newVertex._vpos; + newVertex._vpos = NULL; + } + _coordData.clear(); _newVertexList.clear(); _primList.clear(); _errorCode = 0; } + class InsertNewVertices : public osg::ArrayVisitor { public: