Fix two gross memory leaks. I was neglecting to clear the SEdgeList

that I created in SPolygon::SelfIntersecting, and while
triangulating a polygon I would free the SContour, but not the
list of points associated with the contour.

[git-p4: depot-paths = "//depot/solvespace/": change = 2047]
This commit is contained in:
Jonathan Westhues 2009-10-02 01:30:12 -08:00
parent 2e9e0da71f
commit 15729c74f0
2 changed files with 14 additions and 2 deletions

View File

@ -562,12 +562,17 @@ bool SPolygon::SelfIntersecting(Vector *intersectsAt) {
ZERO(&el);
MakeEdgesInto(&el);
bool ret = false;
SEdge *se;
for(se = el.l.First(); se; se = el.l.NextAfter(se)) {
int inters = el.AnyEdgeCrossings(se->a, se->b, intersectsAt);
if(inters != 1) return true;
if(inters != 1) {
ret = true;
break;
}
}
return false;
el.Clear();
return ret;
}
static int TriMode, TriVertexCount;

View File

@ -89,6 +89,13 @@ void SPolygon::UvTriangulateInto(SMesh *m, SSurface *srf) {
el.Clear();
vl.Clear();
// Careful, need to free the points within the contours, and not just
// the contours themselves. This was a tricky memory leak.
for(sc = l.First(); sc; sc = l.NextAfter(sc)) {
if(sc->tag) {
sc->l.Clear();
}
}
l.RemoveTagged();
}
}