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,4 +1,4 @@
// Copyright (C) 2009 Laboratoire de Recherche et Développement
// Copyright (C) 2009, 2011 Laboratoire de Recherche et Développement
// de l'Epita (LRDE).
// Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6
// (LIP6), département Systèmes Répartis Coopératifs (SRC), Université
@ -74,6 +74,27 @@ namespace spot
/// Duplicate a state.
virtual state* clone() const = 0;
/// \brief Release a state.
///
/// Methods from the tgba or tgba_succ_iterator always return a
/// new state that you should deallocate with this function.
/// Before Spot 0.7, you had to "delete" your state directly.
/// Starting with Spot 0.7, you update your code to this function
/// instead (which simply calls "delete"). In a future version,
/// some subclasses will redefine destroy() to allow better memory
/// management (e.g. no memory allocation for explicit automata).
virtual void destroy() const
{
delete this;
}
// FIXME: Make the destructor protected after Spot 0.7.
//protected:
/// \brief Destructor.
///
/// \deprecated Client code should now call
/// <code>s->destroy();</code> instead of <code>delete s;</code>.
virtual ~state()
{
}
@ -156,6 +177,8 @@ namespace spot
typedef boost::shared_ptr<const state> shared_state;
inline void shared_state_deleter(state* s) { s->destroy(); }
/// \brief Strict Weak Ordering for \c shared_state
/// (shared_ptr<const state*>).
/// \ingroup tgba_essentials