Moved an auto_ptr up into main, since the memory it governs must still be
available to the exception handlers that come immediately after it.
This commit is contained in:
parent
d0669f8402
commit
5f472969cd
1 changed files with 10 additions and 4 deletions
14
main.cc
14
main.cc
|
|
@ -22,8 +22,8 @@
|
||||||
|
|
||||||
using namespace ledger;
|
using namespace ledger;
|
||||||
|
|
||||||
int parse_and_report(config_t& config, report_t& report,
|
int parse_and_report(config_t& config, std::auto_ptr<journal_t>& journal,
|
||||||
int argc, char * argv[], char * envp[])
|
report_t& report, int argc, char * argv[], char * envp[])
|
||||||
{
|
{
|
||||||
// Configure the terminus for value expressions
|
// Configure the terminus for value expressions
|
||||||
|
|
||||||
|
|
@ -144,7 +144,7 @@ int parse_and_report(config_t& config, report_t& report,
|
||||||
|
|
||||||
// Parse initialization files, ledger data, price database, etc.
|
// Parse initialization files, ledger data, price database, etc.
|
||||||
|
|
||||||
std::auto_ptr<journal_t> journal(new journal_t);
|
journal.reset(new journal_t);
|
||||||
|
|
||||||
{ TRACE_PUSH(parser, "Parsing journal file");
|
{ TRACE_PUSH(parser, "Parsing journal file");
|
||||||
|
|
||||||
|
|
@ -440,6 +440,12 @@ appending the output of this command to your Ledger file if you so choose."
|
||||||
|
|
||||||
int main(int argc, char * argv[], char * envp[])
|
int main(int argc, char * argv[], char * envp[])
|
||||||
{
|
{
|
||||||
|
// This variable must be defined here so that any memory it holds is still
|
||||||
|
// available should the subsequent exception handlers catch an inner
|
||||||
|
// exception and need to report something on the invalid state of the
|
||||||
|
// journal (such as an unbalanced entry).
|
||||||
|
std::auto_ptr<journal_t> journal;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
#if DEBUG_LEVEL < BETA
|
#if DEBUG_LEVEL < BETA
|
||||||
ledger::do_cleanup = false;
|
ledger::do_cleanup = false;
|
||||||
|
|
@ -449,7 +455,7 @@ int main(int argc, char * argv[], char * envp[])
|
||||||
ledger::config = &config;
|
ledger::config = &config;
|
||||||
ledger::report = &report;
|
ledger::report = &report;
|
||||||
TRACE_PUSH(main, "Ledger starting");
|
TRACE_PUSH(main, "Ledger starting");
|
||||||
int status = parse_and_report(config, report, argc, argv, envp);
|
int status = parse_and_report(config, journal, report, argc, argv, envp);
|
||||||
TRACE_POP(main, "Ledger done");
|
TRACE_POP(main, "Ledger done");
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue