fix memory leak in tgconstruct
This commit is contained in:
parent
d13ec65114
commit
ecb1653eee
4 changed files with 10 additions and 10 deletions
|
@ -49,10 +49,6 @@ TGConstruct::TGConstruct( const TGAreaDefinitions& areas, unsigned int s, SGLock
|
|||
|
||||
// Destructor
|
||||
TGConstruct::~TGConstruct() {
|
||||
// land class polygons
|
||||
polys_in.clear();
|
||||
polys_clipped.clear();
|
||||
|
||||
// All Nodes
|
||||
nodes.clear();
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#include <simgear/threads/SGQueue.hxx>
|
||||
|
||||
#include <Array/array.hxx>
|
||||
#include <terragear//tg_nodes.hxx>
|
||||
#include <terragear/tg_nodes.hxx>
|
||||
#include <landcover/landcover.hxx>
|
||||
|
||||
#include "tglandclass.hxx"
|
||||
|
|
|
@ -45,8 +45,7 @@ int TGConstruct::LoadLandclassPolys( void ) {
|
|||
string base = bucket.gen_base_path();
|
||||
string poly_path;
|
||||
int total_polys_read = 0;
|
||||
|
||||
polys_in.clear();
|
||||
tgPolygon poly;
|
||||
|
||||
// load 2D polygons from all directories provided
|
||||
for ( i = 0; i < (int)load_dirs.size(); ++i ) {
|
||||
|
@ -82,7 +81,6 @@ int TGConstruct::LoadLandclassPolys( void ) {
|
|||
SG_LOG( SG_GENERAL, SG_DEBUG, " Load " << count << " polys from " << p.realpath() );
|
||||
|
||||
for ( unsigned int i=0; i<count; i++ ) {
|
||||
tgPolygon poly;
|
||||
poly.LoadFromGzFile( fp );
|
||||
area = area_defs.get_area_priority( poly.GetFlag() );
|
||||
material = area_defs.get_area_name( area );
|
||||
|
|
|
@ -45,8 +45,11 @@ class TGLandclass
|
|||
{
|
||||
public:
|
||||
TGLandclass() {};
|
||||
~TGLandclass() {};
|
||||
|
||||
void init( unsigned int num_areas) {
|
||||
clear();
|
||||
|
||||
for (unsigned int i=0; i<num_areas; i++) {
|
||||
tgpolygon_list lc;
|
||||
lc.clear();
|
||||
|
@ -65,18 +68,21 @@ public:
|
|||
{
|
||||
return polys[area][poly];
|
||||
}
|
||||
inline tgPolygon & get_poly( unsigned int area, unsigned int poly )
|
||||
inline tgPolygon& get_poly( unsigned int area, unsigned int poly )
|
||||
{
|
||||
return polys[area][poly];
|
||||
}
|
||||
inline void add_poly( unsigned int area, const tgPolygon& p )
|
||||
{
|
||||
if ( area > polys.capacity() ) {
|
||||
SG_LOG( SG_CLIPPER, SG_ALERT, " area out of bounds " << area << " of " << polys.capacity() );
|
||||
SG_LOG( SG_GENERAL, SG_ALERT, " area out of bounds " << area << " of " << polys.capacity() );
|
||||
exit(0);
|
||||
}
|
||||
polys[area].push_back( p );
|
||||
}
|
||||
|
||||
// TODO : Let's get rid of this - it was a memory leak, and the polygons should really be modified in place
|
||||
// NOTE - this will be considerable work, so leaving as is for now (but fix the leak)
|
||||
inline void set_poly( unsigned int area, unsigned int poly, const tgPolygon& p )
|
||||
{
|
||||
polys[area][poly] = p;
|
||||
|
|
Loading…
Reference in a new issue