1
0
Fork 0

Minor improvements for resource management

This commit is contained in:
Scott Giese 2019-01-27 13:21:08 -06:00
parent 4d0a32044d
commit a8677d4f16
4 changed files with 9 additions and 3 deletions

View file

@ -165,15 +165,17 @@ long int tgChopper::GenerateIndex( std::string path )
if ( fread( (void*)&index, sizeof(long int), 1, fp ) != 1 )
{
SG_LOG(SG_GENERAL, SG_ALERT, "Error reading Index file " << index_file << " abort");
fclose( fp );
boost::interprocess::named_mutex::remove("tgChopper_index2");
exit(0);
}
rewind( fp );
}
index++;
rewind( fp );
fwrite( (void*)&index, sizeof(long int), 1, fp );
fclose( fp );
}

View file

@ -185,7 +185,7 @@ void processLayer(OGRLayer* poLayer, tgChopper& results )
char* srsWkt;
oSourceSRS->exportToWkt(&srsWkt);
SG_LOG( SG_GENERAL, SG_DEBUG, "Source spatial reference system: " << srsWkt );
OGRFree(srsWkt);
CPLFree(srsWkt);
oTargetSRS.SetWellKnownGeogCS( "WGS84" );
@ -417,6 +417,7 @@ int main( int argc, char **argv ) {
}
GDALClose(poDS);
GDALDestroyDriverManager();
SG_LOG(SG_GENERAL, SG_ALERT, "Saving to buckets");
results.Add_Extension("cliffs");

View file

@ -532,6 +532,8 @@ int main(int argc, const char **argv)
}
}
GDALDestroyDriverManager();
auto finish_time = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> elapsed = finish_time - start_time;
std::cout << std::endl << "Elapsed time: " << elapsed.count() << " seconds" << std::endl << std::endl;

View file

@ -459,6 +459,7 @@ void processLayer(OGRLayer* poLayer, tgChopper& results )
SG_LOG( SG_GENERAL, SG_ALERT, "Error in query expression '" << attribute_query << "'" );
if (!continue_on_errors) {
SG_LOG( SG_GENERAL, SG_ALERT, "Aborting!" );
OCTDestroyCoordinateTransformation ( poCT );
exit( 1 );
}
else