summaryrefslogtreecommitdiff
path: root/src/main.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2012-03-11 04:55:51 -0500
committerJohn Wiegley <johnw@newartisans.com>2012-03-11 04:55:51 -0500
commit020de80f6012bb323f11da77e0ca3c8841999491 (patch)
tree1a41e9ce8973a3ea62c0d310cd3e0db0f0bfeead /src/main.cc
parent234348f7fa9018506e740996e8efb5afee283841 (diff)
downloadfork-ledger-020de80f6012bb323f11da77e0ca3c8841999491.tar.gz
fork-ledger-020de80f6012bb323f11da77e0ca3c8841999491.tar.bz2
fork-ledger-020de80f6012bb323f11da77e0ca3c8841999491.zip
Make sure not to free global_scope unless --verify
Diffstat (limited to 'src/main.cc')
-rw-r--r--src/main.cc13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/main.cc b/src/main.cc
index 5f435d0b..e341b526 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -80,12 +80,12 @@ int main(int argc, char * argv[], char * envp[])
::textdomain("ledger");
#endif
- unique_ptr<global_scope_t> global_scope;
+ global_scope_t * global_scope = NULL;
try {
// Create the session object, which maintains nearly all state relating to
// this invocation of Ledger; and register all known journal parsers.
- global_scope.reset(new global_scope_t(envp));
+ global_scope = new global_scope_t(envp);
global_scope->session().set_flush_on_next_data_file(true);
// Construct an STL-style argument list from the process command arguments
@@ -94,7 +94,7 @@ int main(int argc, char * argv[], char * envp[])
args.push_back(argv[i]);
// Look for options and a command verb in the command-line arguments
- bind_scope_t bound_scope(*global_scope.get(), global_scope->report());
+ bind_scope_t bound_scope(*global_scope, global_scope->report());
args = global_scope->read_command_arguments(bound_scope, args);
if (global_scope->HANDLED(script_)) {
@@ -185,7 +185,7 @@ int main(int argc, char * argv[], char * envp[])
}
}
catch (const std::exception& err) {
- if (global_scope.get())
+ if (global_scope)
global_scope->report_error(err);
else
std::cerr << "Exception during initialization: " << err.what()
@@ -202,15 +202,14 @@ int main(int argc, char * argv[], char * envp[])
// then shutting down the memory tracing subsystem. Otherwise, let it all
// leak because we're about to exit anyway.
IF_VERIFY() {
- global_scope.reset();
+ checked_delete(global_scope);
INFO("Ledger ended (Boost/libstdc++ may still hold memory)");
#if defined(VERIFY_ON)
shutdown_memory_tracing();
#endif
} else {
- global_scope.release(); // let it leak!
- INFO("Ledger ended");
+ INFO("Ledger ended"); // let global_scope leak!
}
// Return the final status to the operating system, either 1 for error or 0