Clean up constructor a bit.

This commit is contained in:
curt 2000-08-08 03:20:02 +00:00
parent 159d3c4c6c
commit 4e23b3dff5
2 changed files with 24 additions and 11 deletions

View File

@ -75,9 +75,11 @@ SGTime::SGTime( double lon, double lat, const string& root )
// cout << "Current local time = " // cout << "Current local time = "
// << asctime(localtime(&cur_time)) << endl; // << asctime(localtime(&cur_time)) << endl;
if ( root != "" ) {
FGPath zone( root ); FGPath zone( root );
zone.append( "zone.tab" ); zone.append( "zone.tab" );
FG_LOG( FG_EVENT, FG_DEBUG, "Reading timezone info from: " << zone.str() ); FG_LOG( FG_EVENT, FG_DEBUG, "Reading timezone info from: "
<< zone.str() );
tzContainer = new TimezoneContainer( zone.c_str() ); tzContainer = new TimezoneContainer( zone.c_str() );
GeoCoord location( RAD_TO_DEG * lat, RAD_TO_DEG * lon ); GeoCoord location( RAD_TO_DEG * lat, RAD_TO_DEG * lon );
@ -87,6 +89,9 @@ SGTime::SGTime( double lon, double lat, const string& root )
name.append( nearestTz->getDescription() ); name.append( nearestTz->getDescription() );
zonename = strdup( name.c_str() ); zonename = strdup( name.c_str() );
// cout << "Using zonename = " << zonename << endl; // cout << "Using zonename = " << zonename << endl;
} else {
tzContainer = NULL;
}
} }
@ -95,9 +100,16 @@ SGTime::SGTime( const string& root ) {
} }
SGTime::SGTime() {
SGTime( 0.0, 0.0, "" );
}
SGTime::~SGTime() SGTime::~SGTime()
{ {
if ( tzContainer != NULL ) {
delete tzContainer; delete tzContainer;
}
if ( zonename != NULL ) { if ( zonename != NULL ) {
delete zonename; delete zonename;

View File

@ -86,6 +86,7 @@ public:
SGTime( double lon, double lat, const string& root ); SGTime( double lon, double lat, const string& root );
SGTime( const string& root ); SGTime( const string& root );
SGTime();
~SGTime(); ~SGTime();
// Update the time related variables // Update the time related variables