[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)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
owl_run = owl_true ;
|
||||||
|
|
||||||
/* Read options & configuration */
|
/* Read options & configuration */
|
||||||
delete new UserInterface(argc, argv) ;
|
delete new UserInterface(argc, argv) ;
|
||||||
|
|
||||||
/* Read input data */
|
if (owl_run)
|
||||||
delete new InputDataReader() ;
|
{
|
||||||
|
/* Read input data */
|
||||||
|
delete new InputDataReader() ;
|
||||||
|
|
||||||
/* Set up signal handlers */
|
/* Set up signal handlers */
|
||||||
struct sigaction action ;
|
struct sigaction action ;
|
||||||
action.sa_flags = 0 ;
|
action.sa_flags = 0 ;
|
||||||
sigemptyset(&action.sa_mask) ;
|
sigemptyset(&action.sa_mask) ;
|
||||||
action.sa_handler = owl_sigint_handler ;
|
action.sa_handler = owl_sigint_handler ;
|
||||||
sigaction(SIGINT, &action, NULL) ;
|
sigaction(SIGINT, &action, NULL) ;
|
||||||
action.sa_handler = owl_sigterm_handler ;
|
action.sa_handler = owl_sigterm_handler ;
|
||||||
sigaction(SIGTERM, &action, NULL) ;
|
sigaction(SIGTERM, &action, NULL) ;
|
||||||
|
|
||||||
/* Run! */
|
/* Run! */
|
||||||
owl_run = owl_true ;
|
Positioning positioning ;
|
||||||
Positioning positioning ;
|
|
||||||
|
|
||||||
/* Clean */
|
/* Clean */
|
||||||
Stock::clear() ;
|
Stock::clear() ;
|
||||||
|
}
|
||||||
|
|
||||||
cerr << argv[0] << ": end." << endl ;
|
cerr << argv[0] << ": end." << endl ;
|
||||||
return 0 ;
|
return 0 ;
|
||||||
|
|
|
@ -293,7 +293,9 @@ void UserInterface::fill_misc_options()
|
||||||
void UserInterface::parse_options()
|
void UserInterface::parse_options()
|
||||||
{
|
{
|
||||||
parse_command_line() ;
|
parse_command_line() ;
|
||||||
print_information_and_exit_if_requested() ;
|
print_information() ;
|
||||||
|
if (! owl_run)
|
||||||
|
return ;
|
||||||
|
|
||||||
parse_file() ;
|
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
|
// Print version if requested
|
||||||
if (Configuration::is_configured("version"))
|
if (Configuration::is_configured("version"))
|
||||||
{
|
{
|
||||||
|
@ -326,18 +330,15 @@ void UserInterface::print_information_and_exit_if_requested() const
|
||||||
"unknown version"
|
"unknown version"
|
||||||
#endif // OWLPS_VERSION
|
#endif // OWLPS_VERSION
|
||||||
<< ".\n" ;
|
<< ".\n" ;
|
||||||
exit_program = true ;
|
owl_run = owl_false ; // Tell main() to exit
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print usage if requested
|
// Print usage if requested
|
||||||
if (Configuration::is_configured("help"))
|
if (Configuration::is_configured("help"))
|
||||||
{
|
{
|
||||||
cout << *cli_options ;
|
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 ;
|
void parse_file(void) const ;
|
||||||
|
|
||||||
/// Prints usage and/or version information if requested by the user
|
/// 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:
|
public:
|
||||||
|
|
Loading…
Reference in New Issue