summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2008-08-10 01:41:59 -0400
committerJohn Wiegley <johnw@newartisans.com>2008-08-10 01:41:59 -0400
commitba02f0a45036a1f9c64cd56533990d3284bcc4cf (patch)
treef261e8d3cadb5d3dccd904b7c8c7fe5e90811aa3
parentc9d575abceb672d1c23383d973adee40daeecda8 (diff)
downloadfork-ledger-ba02f0a45036a1f9c64cd56533990d3284bcc4cf.tar.gz
fork-ledger-ba02f0a45036a1f9c64cd56533990d3284bcc4cf.tar.bz2
fork-ledger-ba02f0a45036a1f9c64cd56533990d3284bcc4cf.zip
Fixed a memory leak that would show up if --verify --verbose was running and
an error or exception occurred.
-rw-r--r--src/account.h16
-rw-r--r--src/flags.h5
-rw-r--r--src/main.cc5
-rw-r--r--src/xact.h16
4 files changed, 34 insertions, 8 deletions
diff --git a/src/account.h b/src/account.h
index 83242583..6b3ea656 100644
--- a/src/account.h
+++ b/src/account.h
@@ -122,11 +122,23 @@ class account_t : public scope_t
: supports_flags<>(), count(0), total_count(0),
virtuals(0), dflags(0)
{
- TRACE_CTOR(xdata_t, "");
+ TRACE_CTOR(account_t::xdata_t, "");
+ }
+ xdata_t(const xdata_t& other)
+ : supports_flags<>(other.flags()),
+ value(other.value),
+ total(other.total),
+ sort_value(other.sort_value),
+ count(other.count),
+ total_count(other.total_count),
+ virtuals(other.virtuals),
+ dflags(other.dflags)
+ {
+ TRACE_CTOR(account_t::xdata_t, "copy");
}
~xdata_t() throw() {
- TRACE_DTOR(xdata_t);
+ TRACE_DTOR(account_t::xdata_t);
}
};
diff --git a/src/flags.h b/src/flags.h
index b75fdc21..3e94ab31 100644
--- a/src/flags.h
+++ b/src/flags.h
@@ -45,9 +45,12 @@ public:
supports_flags() : flags_(0) {
TRACE_CTOR(supports_flags, "");
}
- supports_flags(const flags_t& arg) : flags_(arg) {
+ supports_flags(const supports_flags& arg) : flags_(arg.flags_) {
TRACE_CTOR(supports_flags, "copy");
}
+ supports_flags(const flags_t& arg) : flags_(arg) {
+ TRACE_CTOR(supports_flags, "const flags_t&");
+ }
~supports_flags() throw() {
TRACE_DTOR(supports_flags);
}
diff --git a/src/main.cc b/src/main.cc
index a5ca02d0..0b89c9f1 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -566,9 +566,7 @@ int main(int argc, char * argv[], char * envp[])
status = read_and_report(*session->current_report.get(), argc, argv, envp);
- if (DO_VERIFY())
- ledger::set_session_context();
- else
+ if (! DO_VERIFY())
session.release(); // don't free anything! just let it leak
}
catch (const std::exception& err) {
@@ -582,6 +580,7 @@ int main(int argc, char * argv[], char * envp[])
IF_VERIFY() {
INFO("Ledger ended (Boost/libstdc++ may still hold memory)");
+ ledger::set_session_context();
ledger::shutdown_memory_tracing();
} else {
INFO("Ledger ended");
diff --git a/src/xact.h b/src/xact.h
index 5d4950f9..bb2f1e23 100644
--- a/src/xact.h
+++ b/src/xact.h
@@ -155,10 +155,22 @@ public:
optional<xacts_list> component_xacts;
xdata_t() : supports_flags<>(), index(0), account(NULL), ptr(NULL) {
- TRACE_CTOR(xdata_t, "");
+ TRACE_CTOR(xact_t::xdata_t, "");
+ }
+ xdata_t(const xdata_t& other)
+ : supports_flags<>(other.flags()),
+ total(other.total),
+ sort_value(other.sort_value),
+ value(other.value),
+ index(other.index),
+ date(other.date),
+ account(other.account),
+ ptr(NULL)
+ {
+ TRACE_CTOR(xact_t::xdata_t, "copy");
}
~xdata_t() throw() {
- TRACE_DTOR(xdata_t);
+ TRACE_DTOR(xact_t::xdata_t);
}
void remember_xact(xact_t& xact) {