From 1fbdf0bcaff52676eb73383f6dec98fc30b00b7c Mon Sep 17 00:00:00 2001 From: Felix Abecassis Date: Fri, 29 Jan 2010 15:26:39 +0100 Subject: [PATCH] * src/tgba/taatgba.cc, src/tgba/taatbga.hh: Fix a memory issue on Darwin. --- ChangeLog | 5 +++++ src/tgba/taatgba.cc | 49 +++++++++++++++++++++++++-------------------- src/tgba/taatgba.hh | 6 +++--- 3 files changed, 35 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index 25f12436d..2e4470f69 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-01-29 Felix Abecassis + + * src/tgba/taatgba.cc, src/tgba/taatbga.hh: Fix a memory issue on + Darwin. + 2010-01-25 Damien Lefortier * wrap/python/cgi/ltl2tgba.in, wrap/python/spot.i: Add a new diff --git a/src/tgba/taatgba.cc b/src/tgba/taatgba.cc index 97ccbe4d2..4d283be1c 100644 --- a/src/tgba/taatgba.cc +++ b/src/tgba/taatgba.cc @@ -246,30 +246,35 @@ namespace spot // If no contradiction, then look for another transition to // merge with the new one. seen_map::iterator i; + std::vector::iterator j; if (t->condition != bddfalse) { - for (i = seen_.find(b); i != seen_.end(); ++i) - { - if (*i->second->dst == *t->dst - && i->second->condition == t->condition) + i = seen_.find(b); + if (i != seen_.end()) + for (j = i->second.begin(); j != i->second.end(); ++j) { - i->second->acceptance_conditions &= t->acceptance_conditions; - break; - } - if (*i->second->dst == *t->dst - && i->second->acceptance_conditions == t->acceptance_conditions) - { - i->second->condition |= t->condition; - break; - } + taa_tgba::transition* current = *j; + if (*current->dst == *t->dst + && current->condition == t->condition) + { + current->acceptance_conditions &= t->acceptance_conditions; + break; + } + if (*current->dst == *t->dst + && current->acceptance_conditions == t->acceptance_conditions) + { + current->condition |= t->condition; + break; + } } } // Mark the new transition as seen and keep it if we have not - // found any contraction and no other transition to merge with, - // or delete it otherwise. - if (t->condition != bddfalse && i == seen_.end()) + // found any contradiction and no other transition to merge + // with, or delete it otherwise. + if (t->condition != bddfalse + && (i == seen_.end() || j == i->second.end())) { - seen_.insert(std::make_pair(b, t)); + seen_[b].push_back(t); succ_.push_back(t); } else @@ -296,11 +301,6 @@ namespace spot taa_succ_iterator::~taa_succ_iterator() { - for (unsigned i = 0; i < succ_.size(); ++i) - { - delete succ_[i]->dst; - delete succ_[i]; - } for (seen_map::iterator i = seen_.begin(); i != seen_.end();) { // Advance the iterator before deleting the state set. @@ -308,6 +308,11 @@ namespace spot ++i; delete s; } + for (unsigned i = 0; i < succ_.size(); ++i) + { + delete succ_[i]->dst; + delete succ_[i]; + } } void diff --git a/src/tgba/taatgba.hh b/src/tgba/taatgba.hh index ebd1a3188..0ee0ebe3d 100644 --- a/src/tgba/taatgba.hh +++ b/src/tgba/taatgba.hh @@ -128,9 +128,9 @@ namespace spot typedef taa_tgba::state::const_iterator iterator; typedef std::pair iterator_pair; typedef std::vector bounds_t; - typedef Sgi::hash_multimap< - const spot::state_set*, taa_tgba::transition*, state_ptr_hash, - state_ptr_equal> seen_map; + typedef Sgi::hash_map< + const spot::state_set*, std::vector, + state_ptr_hash, state_ptr_equal> seen_map; struct distance_sort : public std::binary_function