1
0
Fork 0

Fix some tiny memory leaks

This commit is contained in:
Torsten Dreyer 2017-06-29 21:56:32 +02:00
parent 5b5e5fc0cc
commit 807f26dfdf

View file

@ -174,13 +174,11 @@ void fit_file(const SGPath& path) {
inarray.parse(bucket); inarray.parse(bucket);
inarray.close(); inarray.close();
ArrayMap *DEM=new ArrayMap(inarray); ArrayMap DEM(inarray);
Terra::GreedySubdivision *mesh; Terra::GreedySubdivision mesh(&DEM);
mesh=new Terra::GreedySubdivision(DEM); greedy_insertion(&mesh);
greedy_insertion(mesh);
gzFile fp; gzFile fp;
if ( (fp = gzopen( outPath.c_str(), "wb9" )) == NULL ) { if ( (fp = gzopen( outPath.c_str(), "wb9" )) == NULL ) {
@ -188,23 +186,20 @@ void fit_file(const SGPath& path) {
return; return;
} }
gzprintf(fp,"%d\n",mesh->pointCount()); gzprintf(fp,"%d\n",mesh.pointCount());
for (int x=0;x<DEM->width;x++) { for (int x=0;x<DEM.width;x++) {
for (int y=0;y<DEM->height;y++) { for (int y=0;y<DEM.height;y++) {
if (mesh->is_used(x,y) != DATA_POINT_USED) if (mesh.is_used(x,y) != DATA_POINT_USED)
continue; continue;
double vx,vy,vz; double vx,vy,vz;
vx=(inarray.get_originx()+x*inarray.get_col_step())/3600.0; vx=(inarray.get_originx()+x*inarray.get_col_step())/3600.0;
vy=(inarray.get_originy()+y*inarray.get_row_step())/3600.0; vy=(inarray.get_originy()+y*inarray.get_row_step())/3600.0;
vz=DEM->eval(x,y); vz=DEM.eval(x,y);
gzprintf(fp,"%+03.8f %+02.8f %0.2f\n",vx,vy,vz); gzprintf(fp,"%+03.8f %+02.8f %0.2f\n",vx,vy,vz);
} }
} }
delete mesh;
delete DEM;
gzclose(fp); gzclose(fp);
} }
@ -352,9 +347,9 @@ int main(int argc, char** argv) {
exit(1); exit(1);
} }
std::vector<FitThread*> threads; std::vector<std::shared_ptr<FitThread> > threads;
for (unsigned int t=0; t<num_threads; ++t) { for (unsigned int t=0; t<num_threads; ++t) {
FitThread* thread = new FitThread; std::shared_ptr<FitThread> thread(new FitThread);
thread->start(); thread->start();
threads.push_back(thread); threads.push_back(thread);
} }