FGLogger::Log: use std::unique_ptr to manage the sg_ofstream instance
No more raw pointer; RAII is good.
This commit is contained in:
parent
b56f694ffd
commit
30aebc783b
2 changed files with 4 additions and 10 deletions
|
@ -80,7 +80,7 @@ FGLogger::init ()
|
|||
log.last_time_ms = globals->get_sim_time_sec() * 1000;
|
||||
log.delimiter = delimiter.c_str()[0];
|
||||
// Security: use the return value of fgValidatePath()
|
||||
log.output = new sg_ofstream(authorizedPath, std::ios_base::out);
|
||||
log.output.reset(new sg_ofstream(authorizedPath, std::ios_base::out));
|
||||
if ( !(*log.output) ) {
|
||||
SG_LOG(SG_GENERAL, SG_ALERT, "Cannot write log to " << filename);
|
||||
_logs.pop_back();
|
||||
|
@ -158,16 +158,10 @@ FGLogger::update (double dt)
|
|||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
FGLogger::Log::Log ()
|
||||
: output(0),
|
||||
interval_ms(0),
|
||||
: interval_ms(0),
|
||||
last_time_ms(-999999.0),
|
||||
delimiter(',')
|
||||
{
|
||||
}
|
||||
|
||||
FGLogger::Log::~Log ()
|
||||
{
|
||||
delete output;
|
||||
}
|
||||
|
||||
// end of logger.cxx
|
||||
|
|
|
@ -34,9 +34,9 @@ private:
|
|||
*/
|
||||
struct Log {
|
||||
Log ();
|
||||
virtual ~Log ();
|
||||
|
||||
std::vector<SGPropertyNode_ptr> nodes;
|
||||
sg_ofstream * output;
|
||||
std::unique_ptr<sg_ofstream> output;
|
||||
long interval_ms;
|
||||
double last_time_ms;
|
||||
char delimiter;
|
||||
|
|
Loading…
Add table
Reference in a new issue