diff options
author | John Wiegley <johnw@newartisans.com> | 2009-02-21 04:12:10 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-02-21 04:12:10 -0400 |
commit | 6548da04cdde83998ec380a1b47117b45b0d65f8 (patch) | |
tree | 7f022ce0139cce4a98f69dd96da4ef70272e5c7d /src/utils.cc | |
parent | aeea1cb3e1c5c158294e1f08543065c2e602c94e (diff) | |
download | fork-ledger-6548da04cdde83998ec380a1b47117b45b0d65f8.tar.gz fork-ledger-6548da04cdde83998ec380a1b47117b45b0d65f8.tar.bz2 fork-ledger-6548da04cdde83998ec380a1b47117b45b0d65f8.zip |
Fixed another memory bug in by_payee_xacts
Diffstat (limited to 'src/utils.cc')
-rw-r--r-- | src/utils.cc | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/utils.cc b/src/utils.cc index d42ed79c..5f42eae5 100644 --- a/src/utils.cc +++ b/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) { - memory_tracing_active = false; - if (! live_objects) return; + memory_tracing_active = false; + DEBUG("memory.debug", "TRACE_DTOR " << ptr << " " << cls_name); live_objects_map::iterator i = live_objects->find(ptr); if (i == live_objects->end()) { std::cerr << "Attempting to delete " << ptr << " a non-living " << cls_name << std::endl; - assert(false); + memory_tracing_active = true; + return; } - int ptr_count = live_objects->count(ptr); - for (int x = 0; x < ptr_count; x++, i++) { + std::size_t ptr_count = live_objects->count(ptr); + for (std::size_t x = 0; x < ptr_count; x++, i++) { if ((*i).second.first == cls_name) { live_objects->erase(i); 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); - 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; if (--(*k).second.first == 0) |