diff options
author | John Wiegley <johnw@newartisans.com> | 2006-02-28 13:06:38 +0000 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-04-13 02:41:28 -0400 |
commit | 9db08c4c7de7b2058363bec4a3000f48fc78d580 (patch) | |
tree | fbb06b002da3baa026e068d78667075f84fcc845 | |
parent | 2930b89ea3e4515e24739357598034db6cb842e0 (diff) | |
download | fork-ledger-9db08c4c7de7b2058363bec4a3000f48fc78d580.tar.gz fork-ledger-9db08c4c7de7b2058363bec4a3000f48fc78d580.tar.bz2 fork-ledger-9db08c4c7de7b2058363bec4a3000f48fc78d580.zip |
(read_binary_journal): Fixed a tiny memory leak when reading from a
binary cache.
-rw-r--r-- | binary.cc | 1 | ||||
-rw-r--r-- | format.h | 12 | ||||
-rw-r--r-- | journal.cc | 2 | ||||
-rw-r--r-- | journal.h | 3 | ||||
-rw-r--r-- | valexpr.cc | 11 | ||||
-rw-r--r-- | valexpr.h | 17 |
6 files changed, 29 insertions, 17 deletions
@@ -557,6 +557,7 @@ unsigned int read_binary_journal(std::istream& in, account_t::ident_t a_count = read_binary_long<account_t::ident_t>(data); accounts = accounts_next = new account_t *[a_count]; + delete journal->master; journal->master = read_binary_account(data, journal, master); if (read_binary_number<bool>(data)) journal->basket = accounts[read_binary_long<account_t::ident_t>(data) - 1]; @@ -45,13 +45,13 @@ struct element_t DEPTH_SPACER }; - bool align_left; - unsigned int min_width; - unsigned int max_width; + bool align_left; + unsigned int min_width; + unsigned int max_width; - kind_t type; - std::string chars; - value_expr * val_expr; + kind_t type; + std::string chars; + value_expr * val_expr; struct element_t * next; @@ -309,7 +309,7 @@ void auto_entry_t::extend_entry(entry_base_t& entry) account_t::~account_t() { - DEBUG_PRINT("ledger.memory.dtors", "dtor account_t"); + DEBUG_PRINT("ledger.memory.dtors", "dtor account_t " << this); //assert(! data); for (accounts_map::iterator i = accounts.begin(); @@ -283,9 +283,8 @@ class account_t const std::string& _note = "") : parent(_parent), name(_name), note(_note), depth(parent ? parent->depth + 1 : 0), data(NULL), ident(0) { - DEBUG_PRINT("ledger.memory.ctors", "ctor account_t"); + DEBUG_PRINT("ledger.memory.ctors", "ctor account_t " << this); } - ~account_t(); bool operator==(const account_t& account) { @@ -44,7 +44,7 @@ bool compute_amount(value_expr_t * expr, amount_t& amt, value_expr_t::~value_expr_t() { - DEBUG_PRINT("ledger.memory.dtors", "dtor value_expr_t"); + DEBUG_PRINT("ledger.memory.dtors", "dtor value_expr_t " << this); DEBUG_PRINT("ledger.valexpr.memory", "Destroying " << this); assert(refc == 0); @@ -1279,7 +1279,8 @@ void init_value_expr() globals->define("P", node); globals->define("val", node); globals->define("value", node); - parse_boolean_expr("current_value(x)=P(x,m)", globals); + node = parse_boolean_expr("current_value(x)=P(x,m)", globals); + delete node; // Macros node = parse_value_expr("P(a,d)"); @@ -1298,8 +1299,10 @@ void init_value_expr() globals->define("G", node); globals->define("gain_total", node); - parse_boolean_expr("min(x,y)=x<y?x:y", globals); - parse_boolean_expr("max(x,y)=x>y?x:y", globals); + node = parse_boolean_expr("min(x,y)=x<y?x:y", globals); + delete node; + node = parse_boolean_expr("max(x,y)=x>y?x:y", globals); + delete node; } value_expr_t * parse_value_expr(std::istream& in, scope_t * scope, @@ -151,7 +151,10 @@ struct value_expr_t value_expr_t(const kind_t _kind) : kind(_kind), refc(0), left(NULL), right(NULL) { - DEBUG_PRINT("ledger.memory.ctors", "ctor value_expr_t"); + DEBUG_PRINT("ledger.memory.ctors", "ctor value_expr_t " << this); + } + value_expr_t(const value_expr_t&) { + DEBUG_PRINT("ledger.memory.ctors", "ctor value_expr_t (copy) " << this); } ~value_expr_t(); @@ -203,8 +206,11 @@ struct scope_t symbol_map symbols; - scope_t(scope_t * _parent = NULL) : parent(_parent) {} + scope_t(scope_t * _parent = NULL) : parent(_parent) { + DEBUG_PRINT("ledger.memory.ctors", "ctor scope_t"); + } ~scope_t() { + DEBUG_PRINT("ledger.memory.dtors", "dtor scope_t"); for (symbol_map::iterator i = symbols.begin(); i != symbols.end(); i++) @@ -328,6 +334,7 @@ class value_expr : public value_calc public: value_expr(const std::string& _expr) : expr(_expr) { + DEBUG_PRINT("ledger.memory.ctors", "ctor value_expr"); try { parsed = parse_value_expr(expr); parsed->acquire(); @@ -337,9 +344,11 @@ public: expr + "': " + err.what()); } } - value_expr(value_expr_t * _parsed) : parsed(_parsed->acquire()) {} - + value_expr(value_expr_t * _parsed) : parsed(_parsed->acquire()) { + DEBUG_PRINT("ledger.memory.ctors", "ctor value_expr"); + } virtual ~value_expr() { + DEBUG_PRINT("ledger.memory.dtors", "dtor value_expr"); if (parsed != NULL) parsed->release(); } |