fixed more memory leaks

This commit is contained in:
zzzzrrr 2010-04-23 11:51:22 -04:00
parent 15db727895
commit 75f8496e22
2 changed files with 12 additions and 4 deletions

View File

@ -88,7 +88,7 @@ Node& Sweep::PointEvent(SweepContext& tcx, Point& point)
// x value than node due to how we fetch nodes from the front // x value than node due to how we fetch nodes from the front
if (point.x <= node.point->x + EPSILON) { if (point.x <= node.point->x + EPSILON) {
Fill(tcx, node); Fill(tcx, node);
tcx.RemoveNode(&node); delete &node;
} }
//tcx.AddNode(new_node); //tcx.AddNode(new_node);
@ -535,19 +535,27 @@ void Sweep::FillBasinReq(SweepContext& tcx, Node* node)
if (o == CW) { if (o == CW) {
return; return;
} }
Node *temp = node;
node = node->next; node = node->next;
delete temp;
} else if (node->next == tcx.basin.right_node) { } else if (node->next == tcx.basin.right_node) {
Orientation o = Orient2d(*node->point, *node->prev->point, *node->prev->prev->point); Orientation o = Orient2d(*node->point, *node->prev->point, *node->prev->prev->point);
if (o == CCW) { if (o == CCW) {
return; return;
} }
Node *temp = node;
node = node->prev; node = node->prev;
delete temp;
} else { } else {
// Continue with the neighbor node with lowest Y value // Continue with the neighbor node with lowest Y value
if (node->prev->point->y < node->next->point->y) { if (node->prev->point->y < node->next->point->y) {
Node *temp = node;
node = node->prev; node = node->prev;
delete temp;
} else { } else {
Node *temp = node;
node = node->next; node = node->next;
delete temp;
} }
} }
@ -702,6 +710,7 @@ void Sweep::FillLeftConcaveEdgeEvent(SweepContext& tcx, Edge* edge, Node& node)
} }
} }
} }
} }
void Sweep::FlipEdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle* t, Point& p) void Sweep::FlipEdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle* t, Point& p)

View File

@ -130,7 +130,6 @@ void SweepContext::CreateAdvancingFront()
head = new Node(*triangle->GetPoint(1), *triangle); head = new Node(*triangle->GetPoint(1), *triangle);
middle = new Node(*triangle->GetPoint(0), *triangle); middle = new Node(*triangle->GetPoint(0), *triangle);
tail = new Node(*triangle->GetPoint(2)); tail = new Node(*triangle->GetPoint(2));
front_ = new AdvancingFront(*head, *tail); front_ = new AdvancingFront(*head, *tail);
// TODO: More intuitive if head is middles next and not previous? // TODO: More intuitive if head is middles next and not previous?