# HG changeset patch # User Alpar Juttner # Date 1444236897 -7200 # Node ID 4124fe8ef8de8ea83e899deabc7749e8f9d28e0a # Parent d94bb1e505573dba7acb630b34de24e328bf40e7# Parent 89e1877e335f0d6c6396bf23ec8c9d2f756d9a7e Merge bugfix #480 to branch 1.2 diff -r d94bb1e50557 -r 4124fe8ef8de tools/lgf-gen.cc --- a/tools/lgf-gen.cc Tue May 26 16:54:15 2015 +0200 +++ b/tools/lgf-gen.cc Wed Oct 07 18:54:57 2015 +0200 @@ -246,7 +246,7 @@ struct BeachIt; - typedef std::multimap SpikeHeap; + typedef std::multimap SpikeHeap; typedef std::multimap Beach; @@ -329,6 +329,7 @@ Beach::iterator bit = beach.upper_bound(Part(site, site, site)); if (bit->second != spikeheap.end()) { + delete bit->second->second; spikeheap.erase(bit->second); } @@ -342,8 +343,8 @@ if (prev != -1 && circle_form(points[prev], points[curr], points[site])) { double x = circle_point(points[prev], points[curr], points[site]); - pit = spikeheap.insert(std::make_pair(x, BeachIt(beach.end()))); - pit->second.it = + pit = spikeheap.insert(std::make_pair(x, new BeachIt(beach.end()))); + pit->second->it = beach.insert(std::make_pair(Part(prev, curr, site), pit)); } else { beach.insert(std::make_pair(Part(prev, curr, site), pit)); @@ -355,8 +356,8 @@ if (next != -1 && circle_form(points[site], points[curr],points[next])) { double x = circle_point(points[site], points[curr], points[next]); - nit = spikeheap.insert(std::make_pair(x, BeachIt(beach.end()))); - nit->second.it = + nit = spikeheap.insert(std::make_pair(x, new BeachIt(beach.end()))); + nit->second->it = beach.insert(std::make_pair(Part(site, curr, next), nit)); } else { beach.insert(std::make_pair(Part(site, curr, next), nit)); @@ -366,7 +367,7 @@ } else { sweep = spit->first; - Beach::iterator bit = spit->second.it; + Beach::iterator bit = spit->second->it; int prev = bit->first.prev; int curr = bit->first.curr; @@ -399,10 +400,22 @@ Beach::iterator nbit = bit; ++nbit; int nnt = nbit->first.next; - if (bit->second != spikeheap.end()) spikeheap.erase(bit->second); - if (pbit->second != spikeheap.end()) spikeheap.erase(pbit->second); - if (nbit->second != spikeheap.end()) spikeheap.erase(nbit->second); - + if (bit->second != spikeheap.end()) + { + delete bit->second->second; + spikeheap.erase(bit->second); + } + if (pbit->second != spikeheap.end()) + { + delete pbit->second->second; + spikeheap.erase(pbit->second); + } + if (nbit->second != spikeheap.end()) + { + delete nbit->second->second; + spikeheap.erase(nbit->second); + } + beach.erase(nbit); beach.erase(bit); beach.erase(pbit); @@ -412,8 +425,8 @@ circle_form(points[ppv], points[prev], points[next])) { double x = circle_point(points[ppv], points[prev], points[next]); if (x < sweep) x = sweep; - pit = spikeheap.insert(std::make_pair(x, BeachIt(beach.end()))); - pit->second.it = + pit = spikeheap.insert(std::make_pair(x, new BeachIt(beach.end()))); + pit->second->it = beach.insert(std::make_pair(Part(ppv, prev, next), pit)); } else { beach.insert(std::make_pair(Part(ppv, prev, next), pit)); @@ -424,8 +437,8 @@ circle_form(points[prev], points[next], points[nnt])) { double x = circle_point(points[prev], points[next], points[nnt]); if (x < sweep) x = sweep; - nit = spikeheap.insert(std::make_pair(x, BeachIt(beach.end()))); - nit->second.it = + nit = spikeheap.insert(std::make_pair(x, new BeachIt(beach.end()))); + nit->second->it = beach.insert(std::make_pair(Part(prev, next, nnt), nit)); } else { beach.insert(std::make_pair(Part(prev, next, nnt), nit));