(read_binary_journal): Fixed a tiny memory leak when reading from a
binary cache.
This commit is contained in:
parent
2930b89ea3
commit
9db08c4c7d
6 changed files with 29 additions and 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];
|
||||
|
|
|
|||
12
format.h
12
format.h
|
|
@ -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) {
|
||||
|
|
|
|||
11
valexpr.cc
11
valexpr.cc
|
|
@ -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,
|
||||
|
|
|
|||
17
valexpr.h
17
valexpr.h
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue