Introduce a destroy() method on states, and use it instead of delete.

Right now, destroy() just executes "delete this".  But in a later
version, we will rewrite tgba_explicit so that it does not
allocate new states (and the destroy() method for explicit state
will do nothing).

* src/tgba/state.hh (state::destroy): New method, to replace
state::~state() in the future.
(shared_state_deleter): New function.
* src/evtgba/product.cc, src/evtgbaalgos/reachiter.cc,
src/evtgbaalgos/save.cc, src/evtgbaalgos/tgba2evtgba.cc,
src/tgba/tgba.cc, src/tgba/tgbaproduct.cc, src/tgba/tgbareduc.cc,
src/tgba/tgbasafracomplement.cc, src/tgba/tgbasgba.cc,
src/tgba/tgbatba.cc, src/tgba/tgbaunion.cc, src/tgba/wdbacomp.cc,
src/tgbaalgos/cutscc.cc, src/tgbaalgos/emptiness.cc,
src/tgbaalgos/gtec/ce.cc, src/tgbaalgos/gtec/explscc.cc,
src/tgbaalgos/gtec/gtec.cc, src/tgbaalgos/gtec/nsheap.cc,
src/tgbaalgos/gv04.cc, src/tgbaalgos/magic.cc,
src/tgbaalgos/minimize.cc, src/tgbaalgos/ndfs_result.hxx,
src/tgbaalgos/neverclaim.cc, src/tgbaalgos/powerset.hh,
src/tgbaalgos/reachiter.cc, src/tgbaalgos/reducerun.cc,
src/tgbaalgos/reductgba_sim.cc,
src/tgbaalgos/reductgba_sim_del.cc, src/tgbaalgos/replayrun.cc,
src/tgbaalgos/safety.cc, src/tgbaalgos/save.cc,
src/tgbaalgos/scc.cc, src/tgbaalgos/se05.cc,
src/tgbaalgos/tau03.cc, src/tgbaalgos/tau03opt.cc: Adjust to call
"s->destroy()" instead of "delete s".
* src/saba/sabacomplementtgba.cc, src/tgba/tgbakvcomplement.cc:
Pass shared_state_deleter to the shared_ptr constructor, so that
it calls destroy() instead of delete.
This commit is contained in:
Alexandre Duret-Lutz 2011-01-25 18:56:42 +01:00
parent 60930d7a12
commit 574a228583
39 changed files with 259 additions and 167 deletions

View file

@ -1,3 +1,5 @@
// Copyright (C) 2011 Laboratoire de Recherche et Développement
// de l'Epita (LRDE).
// Copyright (C) 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
// et Marie Curie.
@ -80,7 +82,7 @@ namespace spot
<< a->format_state(i->s) << std::endl
<< "does not match initial state of automata: "
<< a->format_state(s) << std::endl;
delete s;
s->destroy();
return false;
}
@ -98,7 +100,7 @@ namespace spot
for (d = o->second.begin(); d != o->second.end(); ++d)
msg << " == " << *d;
o->second.insert(serial);
delete s;
s->destroy();
s = o->first;
}
else
@ -142,7 +144,7 @@ namespace spot
// When not debugging, S is not used as key in SEEN, so we can
// delete it right now.
if (!debug)
delete s;
s->destroy();
for (j->first(); !j->done(); j->next())
{
if (j->current_condition() != label
@ -152,7 +154,7 @@ namespace spot
const state* s2 = j->current_state();
if (s2->compare(next))
{
delete s2;
s2->destroy();
continue;
}
else
@ -185,11 +187,11 @@ namespace spot
<< bdd_format_accset(a->get_dict(),
j->current_acceptance_conditions())
<< " going to " << a->format_state(s2) << std::endl;
delete s2;
s2->destroy();
}
}
delete j;
delete s;
s->destroy();
return false;
}
if (debug)
@ -232,7 +234,7 @@ namespace spot
}
}
}
delete s;
s->destroy();
if (all_acc != expected_all_acc)
{
if (debug)
@ -251,7 +253,7 @@ namespace spot
// Advance the iterator before deleting the "key" pointer.
const state* ptr = o->first;
++o;
delete ptr;
ptr->destroy();
}
return true;