Fixed another memory bug in by_payee_xacts
This commit is contained in:
parent
aeea1cb3e1
commit
6548da04cd
3 changed files with 21 additions and 20 deletions
|
|
@ -596,14 +596,6 @@ void xacts_as_equity::report_subtotal()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
by_payee_xacts::~by_payee_xacts()
|
|
||||||
{
|
|
||||||
TRACE_DTOR(by_payee_xacts);
|
|
||||||
|
|
||||||
foreach (payee_subtotals_map::value_type& pair, payee_subtotals)
|
|
||||||
checked_delete(pair.second);
|
|
||||||
}
|
|
||||||
|
|
||||||
void by_payee_xacts::flush()
|
void by_payee_xacts::flush()
|
||||||
{
|
{
|
||||||
foreach (payee_subtotals_map::value_type& pair, payee_subtotals)
|
foreach (payee_subtotals_map::value_type& pair, payee_subtotals)
|
||||||
|
|
@ -618,8 +610,9 @@ void by_payee_xacts::operator()(xact_t& xact)
|
||||||
{
|
{
|
||||||
payee_subtotals_map::iterator i = payee_subtotals.find(xact.entry->payee);
|
payee_subtotals_map::iterator i = payee_subtotals.find(xact.entry->payee);
|
||||||
if (i == payee_subtotals.end()) {
|
if (i == payee_subtotals.end()) {
|
||||||
payee_subtotals_pair temp(xact.entry->payee,
|
payee_subtotals_pair
|
||||||
new subtotal_xacts(handler, amount_expr));
|
temp(xact.entry->payee,
|
||||||
|
shared_ptr<subtotal_xacts>(new subtotal_xacts(handler, amount_expr)));
|
||||||
std::pair<payee_subtotals_map::iterator, bool> result
|
std::pair<payee_subtotals_map::iterator, bool> result
|
||||||
= payee_subtotals.insert(temp);
|
= payee_subtotals.insert(temp);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -651,8 +651,8 @@ public:
|
||||||
*/
|
*/
|
||||||
class by_payee_xacts : public item_handler<xact_t>
|
class by_payee_xacts : public item_handler<xact_t>
|
||||||
{
|
{
|
||||||
typedef std::map<string, subtotal_xacts *> payee_subtotals_map;
|
typedef std::map<string, shared_ptr<subtotal_xacts> > payee_subtotals_map;
|
||||||
typedef std::pair<string, subtotal_xacts *> payee_subtotals_pair;
|
typedef std::pair<string, shared_ptr<subtotal_xacts> > payee_subtotals_pair;
|
||||||
|
|
||||||
expr_t& amount_expr;
|
expr_t& amount_expr;
|
||||||
payee_subtotals_map payee_subtotals;
|
payee_subtotals_map payee_subtotals;
|
||||||
|
|
@ -664,7 +664,9 @@ class by_payee_xacts : public item_handler<xact_t>
|
||||||
: item_handler<xact_t>(handler), amount_expr(_amount_expr) {
|
: item_handler<xact_t>(handler), amount_expr(_amount_expr) {
|
||||||
TRACE_CTOR(by_payee_xacts, "xact_handler_ptr, expr_t&");
|
TRACE_CTOR(by_payee_xacts, "xact_handler_ptr, expr_t&");
|
||||||
}
|
}
|
||||||
virtual ~by_payee_xacts();
|
virtual ~by_payee_xacts() {
|
||||||
|
TRACE_DTOR(by_payee_xacts);
|
||||||
|
}
|
||||||
|
|
||||||
virtual void flush();
|
virtual void flush();
|
||||||
virtual void operator()(xact_t& xact);
|
virtual void operator()(xact_t& xact);
|
||||||
|
|
@ -755,7 +757,7 @@ protected:
|
||||||
public:
|
public:
|
||||||
generate_xacts(xact_handler_ptr handler)
|
generate_xacts(xact_handler_ptr handler)
|
||||||
: item_handler<xact_t>(handler) {
|
: item_handler<xact_t>(handler) {
|
||||||
TRACE_CTOR(dow_xacts, "xact_handler_ptr");
|
TRACE_CTOR(generate_xacts, "xact_handler_ptr");
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~generate_xacts() {
|
virtual ~generate_xacts() {
|
||||||
|
|
|
||||||
18
src/utils.cc
18
src/utils.cc
|
|
@ -292,21 +292,22 @@ void trace_ctor_func(void * ptr, const char * cls_name, const char * args,
|
||||||
|
|
||||||
void trace_dtor_func(void * ptr, const char * cls_name, std::size_t cls_size)
|
void trace_dtor_func(void * ptr, const char * cls_name, std::size_t cls_size)
|
||||||
{
|
{
|
||||||
memory_tracing_active = false;
|
|
||||||
|
|
||||||
if (! live_objects) return;
|
if (! live_objects) return;
|
||||||
|
|
||||||
|
memory_tracing_active = false;
|
||||||
|
|
||||||
DEBUG("memory.debug", "TRACE_DTOR " << ptr << " " << cls_name);
|
DEBUG("memory.debug", "TRACE_DTOR " << ptr << " " << cls_name);
|
||||||
|
|
||||||
live_objects_map::iterator i = live_objects->find(ptr);
|
live_objects_map::iterator i = live_objects->find(ptr);
|
||||||
if (i == live_objects->end()) {
|
if (i == live_objects->end()) {
|
||||||
std::cerr << "Attempting to delete " << ptr << " a non-living " << cls_name
|
std::cerr << "Attempting to delete " << ptr << " a non-living " << cls_name
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
assert(false);
|
memory_tracing_active = true;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ptr_count = live_objects->count(ptr);
|
std::size_t ptr_count = live_objects->count(ptr);
|
||||||
for (int x = 0; x < ptr_count; x++, i++) {
|
for (std::size_t x = 0; x < ptr_count; x++, i++) {
|
||||||
if ((*i).second.first == cls_name) {
|
if ((*i).second.first == cls_name) {
|
||||||
live_objects->erase(i);
|
live_objects->erase(i);
|
||||||
break;
|
break;
|
||||||
|
|
@ -314,7 +315,12 @@ void trace_dtor_func(void * ptr, const char * cls_name, std::size_t cls_size)
|
||||||
}
|
}
|
||||||
|
|
||||||
object_count_map::iterator k = live_object_count->find(cls_name);
|
object_count_map::iterator k = live_object_count->find(cls_name);
|
||||||
VERIFY(k != live_object_count->end());
|
if (k == live_object_count->end()) {
|
||||||
|
std::cerr << "Failed to find " << cls_name << " in live object counts"
|
||||||
|
<< std::endl;
|
||||||
|
memory_tracing_active = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
(*k).second.second -= cls_size;
|
(*k).second.second -= cls_size;
|
||||||
if (--(*k).second.first == 0)
|
if (--(*k).second.first == 0)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue