[Positioning] Fix config parsing memory leaks
Do not use exit() from UserInterface::print_information_and_exit_if_requested(), set owl_run to false instead. This function is renamed print_information().
This commit is contained in:
parent
1a98cf44b2
commit
b57bf543c7
|
@ -14,27 +14,31 @@ using namespace std ;
|
|||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
owl_run = owl_true ;
|
||||
|
||||
/* Read options & configuration */
|
||||
delete new UserInterface(argc, argv) ;
|
||||
|
||||
/* Read input data */
|
||||
delete new InputDataReader() ;
|
||||
if (owl_run)
|
||||
{
|
||||
/* Read input data */
|
||||
delete new InputDataReader() ;
|
||||
|
||||
/* Set up signal handlers */
|
||||
struct sigaction action ;
|
||||
action.sa_flags = 0 ;
|
||||
sigemptyset(&action.sa_mask) ;
|
||||
action.sa_handler = owl_sigint_handler ;
|
||||
sigaction(SIGINT, &action, NULL) ;
|
||||
action.sa_handler = owl_sigterm_handler ;
|
||||
sigaction(SIGTERM, &action, NULL) ;
|
||||
/* Set up signal handlers */
|
||||
struct sigaction action ;
|
||||
action.sa_flags = 0 ;
|
||||
sigemptyset(&action.sa_mask) ;
|
||||
action.sa_handler = owl_sigint_handler ;
|
||||
sigaction(SIGINT, &action, NULL) ;
|
||||
action.sa_handler = owl_sigterm_handler ;
|
||||
sigaction(SIGTERM, &action, NULL) ;
|
||||
|
||||
/* Run! */
|
||||
owl_run = owl_true ;
|
||||
Positioning positioning ;
|
||||
/* Run! */
|
||||
Positioning positioning ;
|
||||
|
||||
/* Clean */
|
||||
Stock::clear() ;
|
||||
/* Clean */
|
||||
Stock::clear() ;
|
||||
}
|
||||
|
||||
cerr << argv[0] << ": end." << endl ;
|
||||
return 0 ;
|
||||
|
|
|
@ -293,7 +293,9 @@ void UserInterface::fill_misc_options()
|
|||
void UserInterface::parse_options()
|
||||
{
|
||||
parse_command_line() ;
|
||||
print_information_and_exit_if_requested() ;
|
||||
print_information() ;
|
||||
if (! owl_run)
|
||||
return ;
|
||||
|
||||
parse_file() ;
|
||||
|
||||
|
@ -310,10 +312,12 @@ void UserInterface::parse_command_line() const
|
|||
}
|
||||
|
||||
|
||||
void UserInterface::print_information_and_exit_if_requested() const
|
||||
/**
|
||||
* If information is printed, owl_run is set to false, to indicate that
|
||||
* the program should stop.
|
||||
*/
|
||||
void UserInterface::print_information() const
|
||||
{
|
||||
bool exit_program = false ;
|
||||
|
||||
// Print version if requested
|
||||
if (Configuration::is_configured("version"))
|
||||
{
|
||||
|
@ -326,18 +330,15 @@ void UserInterface::print_information_and_exit_if_requested() const
|
|||
"unknown version"
|
||||
#endif // OWLPS_VERSION
|
||||
<< ".\n" ;
|
||||
exit_program = true ;
|
||||
owl_run = owl_false ; // Tell main() to exit
|
||||
}
|
||||
|
||||
// Print usage if requested
|
||||
if (Configuration::is_configured("help"))
|
||||
{
|
||||
cout << *cli_options ;
|
||||
exit_program = true ;
|
||||
owl_run = owl_false ; // Tell main() to exit
|
||||
}
|
||||
|
||||
if (exit_program)
|
||||
exit(0) ;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ protected:
|
|||
void parse_file(void) const ;
|
||||
|
||||
/// Prints usage and/or version information if requested by the user
|
||||
void print_information_and_exit_if_requested(void) const ;
|
||||
void print_information(void) const ;
|
||||
//@}
|
||||
|
||||
public:
|
||||
|
|
Loading…
Reference in New Issue