* iface/gspn/eesrg.cc (tgba_succ_iterator_gspn_eesrg::step): Fix

the iteration logic.
(tgba_succ_iterator_gspn_eesrg::tgba_succ_iterator_gspn_eesrg): Make
sure not to free successors_ twice.
(tgba_succ_iterator_gspn_eesrg::done): Fix definition.
This commit is contained in:
Alexandre Duret-Lutz 2003-11-06 17:50:35 +00:00
parent f7851c17c0
commit f31caafb50
2 changed files with 21 additions and 12 deletions

View file

@ -1,5 +1,11 @@
2003-11-06 Alexandre Duret-Lutz <adl@src.lip6.fr> 2003-11-06 Alexandre Duret-Lutz <adl@src.lip6.fr>
* iface/gspn/eesrg.cc (tgba_succ_iterator_gspn_eesrg::step): Fix
the iteration logic.
(tgba_succ_iterator_gspn_eesrg::tgba_succ_iterator_gspn_eesrg): Make
sure not to free successors_ twice.
(tgba_succ_iterator_gspn_eesrg::done): Fix definition.
* iface/gspn/eesrg.cc (tgba_gspn_eesrg::get_init_state): Do not * iface/gspn/eesrg.cc (tgba_gspn_eesrg::get_init_state): Do not
call get_init_state(), use 0 instead. call get_init_state(), use 0 instead.
(tgba_gspn_eesrg::format_state): Handle the case where s->left() == 0. (tgba_gspn_eesrg::format_state): Handle the case where s->left() == 0.

View file

@ -169,31 +169,34 @@ namespace spot
virtual virtual
~tgba_succ_iterator_gspn_eesrg() ~tgba_succ_iterator_gspn_eesrg()
{ {
// If the iterator is done, successors_ has already
// been freed from step(). (We can't use 0 do indicate
// this, because successor_==0 means something else to step().)
if (successors_ && !done())
succ_free(successors_);
if (operand_) if (operand_)
delete operand_; delete operand_;
if (successors_)
succ_free(successors_);
} }
void void
step() step()
{ {
if (current_ < size_) if (++current_ < size_)
{ return;
++current_;
return;
}
if (successors_) if (successors_)
succ_free(successors_); succ_free(successors_);
current_ = 0;
if (all_conds_ == bddfalse) if (all_conds_ == bddfalse)
{ {
// SUCCESSORS_ is 0 when step() is called from first(). // SUCCESSORS_ is 0 when step() is called from first().
if (successors_) if (successors_)
operand_->next(); {
assert(!operand_->done());
operand_->next();
}
if (operand_->done())
return;
all_conds_ = operand_->current_condition(); all_conds_ = operand_->current_condition();
outside_ = !all_conds_; outside_ = !all_conds_;
} }
@ -234,6 +237,7 @@ namespace spot
} }
succ(state_, props, &successors_, &size_); succ(state_, props, &successors_, &size_);
current_ = 0;
} }
virtual void virtual void
@ -268,8 +272,7 @@ namespace spot
{ {
return (size_ <= current_ return (size_ <= current_
&& all_conds_ == bddfalse && all_conds_ == bddfalse
&& operand_ && (!operand_ || operand_->done()));
&& operand_->done());
} }
virtual state* virtual state*