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:
parent
60930d7a12
commit
574a228583
39 changed files with 259 additions and 167 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
// Copyright (C) 2011 Laboratoire de Recherche et Developpement de
|
||||
// l'EPITA (LRDE).
|
||||
// Copyright (C) 2003, 2004, 2005 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
||||
// et Marie Curie.
|
||||
|
|
@ -32,8 +34,10 @@ namespace spot
|
|||
|
||||
tgba::~tgba()
|
||||
{
|
||||
delete last_support_conditions_input_;
|
||||
delete last_support_variables_input_;
|
||||
if (last_support_conditions_input_)
|
||||
last_support_conditions_input_->destroy();
|
||||
if (last_support_variables_input_)
|
||||
last_support_variables_input_->destroy();
|
||||
}
|
||||
|
||||
bdd
|
||||
|
|
@ -43,7 +47,8 @@ namespace spot
|
|||
|| last_support_conditions_input_->compare(state) != 0)
|
||||
{
|
||||
last_support_conditions_output_ = compute_support_conditions(state);
|
||||
delete last_support_conditions_input_;
|
||||
if (last_support_conditions_input_)
|
||||
last_support_conditions_input_->destroy();
|
||||
last_support_conditions_input_ = state->clone();
|
||||
}
|
||||
return last_support_conditions_output_;
|
||||
|
|
@ -56,7 +61,8 @@ namespace spot
|
|||
|| last_support_variables_input_->compare(state) != 0)
|
||||
{
|
||||
last_support_variables_output_ = compute_support_variables(state);
|
||||
delete last_support_variables_input_;
|
||||
if (last_support_variables_input_)
|
||||
last_support_variables_input_->destroy();
|
||||
last_support_variables_input_ = state->clone();
|
||||
}
|
||||
return last_support_variables_output_;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2009, 2010 Laboratoire de Recherche et Développement
|
||||
// Copyright (C) 2009, 2010, 2011 Laboratoire de Recherche et Développement
|
||||
// de l'Epita (LRDE).
|
||||
//
|
||||
// This file is part of Spot, a model checking library.
|
||||
|
|
@ -443,7 +443,7 @@ namespace spot
|
|||
bdd c = iterator->current_condition();
|
||||
if ((c & condition) != bddfalse)
|
||||
{
|
||||
shared_state s(iterator->current_state());
|
||||
shared_state s(iterator->current_state(), shared_state_deleter);
|
||||
if (highest_current_ranks_.find(s) != highest_current_ranks_.end())
|
||||
{
|
||||
if (i->second < highest_current_ranks_[s])
|
||||
|
|
@ -470,7 +470,7 @@ namespace spot
|
|||
bdd c = iterator->current_condition();
|
||||
if ((c & condition) != bddfalse)
|
||||
{
|
||||
shared_state s(iterator->current_state());
|
||||
shared_state s(iterator->current_state(), shared_state_deleter);
|
||||
highest_state_set_.insert(s);
|
||||
}
|
||||
}
|
||||
|
|
@ -621,7 +621,8 @@ namespace spot
|
|||
{
|
||||
state_kv_complement* init = new state_kv_complement();
|
||||
rank_t r = {2 * nb_states_, bdd_ordered()};
|
||||
init->add(shared_state(automaton_->get_init_state()), r);
|
||||
init->add(shared_state(automaton_->get_init_state(), shared_state_deleter),
|
||||
r);
|
||||
return init;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,8 +41,8 @@ namespace spot
|
|||
|
||||
state_product::~state_product()
|
||||
{
|
||||
delete left_;
|
||||
delete right_;
|
||||
left_->destroy();
|
||||
right_->destroy();
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright (C) 2008, 2009 Laboratoire de Recherche et Développement
|
||||
// de l'Epita (LRDE).
|
||||
// Copyright (C) 2008, 2009, 2011 Laboratoire de Recherche et
|
||||
// Developpement de l'Epita (LRDE).
|
||||
// Copyright (C) 2004, 2005 Laboratoire d'Informatique de Paris
|
||||
// 6 (LIP6), département Systèmes Répartis Coopératifs (SRC),
|
||||
// Université Pierre et Marie Curie.
|
||||
|
|
@ -156,7 +156,7 @@ namespace spot
|
|||
spot::state* init = automata_->get_init_state();
|
||||
if (init->compare(s) == 0)
|
||||
this->set_init_state(automata_->format_state(s));
|
||||
delete init;
|
||||
init->destroy();
|
||||
|
||||
transition* t;
|
||||
for (si->first(); !si->done(); si->next())
|
||||
|
|
@ -165,7 +165,7 @@ namespace spot
|
|||
t = this->create_transition(s, init);
|
||||
this->add_conditions(t, si->current_condition());
|
||||
this->add_acceptance_conditions(t, si->current_acceptance_conditions());
|
||||
delete init;
|
||||
init->destroy();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -361,7 +361,7 @@ namespace spot
|
|||
sim1 = sim2;
|
||||
sim2 = simtmp;
|
||||
}
|
||||
delete init;
|
||||
init->destroy();
|
||||
|
||||
sp_map::iterator i = state_predecessor_map_.find(s1);
|
||||
if (i == state_predecessor_map_.end()) // 0 predecessor
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2009, 2010 Laboratoire de Recherche et Développement
|
||||
// Copyright (C) 2009, 2010, 2011 Laboratoire de Recherche et Développement
|
||||
// de l'Epita (LRDE).
|
||||
//
|
||||
// This file is part of Spot, a model checking library.
|
||||
|
|
@ -170,7 +170,7 @@ namespace spot
|
|||
delete *i;
|
||||
|
||||
for (subset_t::iterator i = nodes.begin(); i != nodes.end(); ++i)
|
||||
delete *i;
|
||||
(*i)->destroy();
|
||||
}
|
||||
|
||||
const safra_tree&
|
||||
|
|
@ -403,7 +403,7 @@ namespace spot
|
|||
const state* s = *node_it;
|
||||
(*child_it)->remove_node_from_children(*node_it);
|
||||
(*child_it)->nodes.erase(node_it++);
|
||||
delete s;
|
||||
s->destroy();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -431,7 +431,7 @@ namespace spot
|
|||
{
|
||||
const spot::state* s = *it;
|
||||
(*child_it)->nodes.erase(it);
|
||||
delete s;
|
||||
s->destroy();
|
||||
}
|
||||
(*child_it)->remove_node_from_children(state);
|
||||
}
|
||||
|
|
@ -679,7 +679,7 @@ namespace spot
|
|||
for (safra_tree::tr_cache_t::iterator j = i->second.begin();
|
||||
j != i->second.end();
|
||||
++j)
|
||||
delete j->second;
|
||||
j->second->destroy();
|
||||
// delete node;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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).
|
||||
//
|
||||
// This file is part of Spot, a model checking library.
|
||||
|
|
@ -48,7 +48,7 @@ namespace spot
|
|||
virtual
|
||||
~state_sgba_proxy()
|
||||
{
|
||||
delete s_;
|
||||
s_->destroy();
|
||||
}
|
||||
|
||||
state*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2010 Laboratoire de Recherche et Développement de
|
||||
// Copyright (C) 2010, 2011 Laboratoire de Recherche et Développement de
|
||||
// l'Epita.
|
||||
// Copyright (C) 2003, 2004, 2005 Laboratoire d'Informatique de Paris
|
||||
// 6 (LIP6), département Systèmes Répartis Coopératifs (SRC),
|
||||
|
|
@ -56,7 +56,7 @@ namespace spot
|
|||
virtual
|
||||
~state_tba_proxy()
|
||||
{
|
||||
delete s_;
|
||||
s_->destroy();
|
||||
}
|
||||
|
||||
state*
|
||||
|
|
@ -204,7 +204,7 @@ namespace spot
|
|||
else // Yes, combine labels.
|
||||
{
|
||||
id->second |= it->current_condition();
|
||||
delete dest;
|
||||
dest->destroy();
|
||||
}
|
||||
}
|
||||
delete it;
|
||||
|
|
@ -219,7 +219,7 @@ namespace spot
|
|||
const state* d = i->first.first;
|
||||
// Advance i before deleting d.
|
||||
++i;
|
||||
delete d;
|
||||
d->destroy();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -318,7 +318,7 @@ namespace spot
|
|||
// Advance the iterator before deleting the key.
|
||||
const state* s = i->first;
|
||||
++i;
|
||||
delete s;
|
||||
s->destroy();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -452,15 +452,15 @@ namespace spot
|
|||
// duplication of the initial state.
|
||||
// The cycle_start_ points to the right starting
|
||||
// point already, so just return.
|
||||
delete dest;
|
||||
dest->destroy();
|
||||
delete it;
|
||||
delete init;
|
||||
init->destroy();
|
||||
return;
|
||||
}
|
||||
delete dest;
|
||||
dest->destroy();
|
||||
}
|
||||
delete it;
|
||||
delete init;
|
||||
init->destroy();
|
||||
}
|
||||
|
||||
// If we arrive here either because the number of acceptance
|
||||
|
|
|
|||
|
|
@ -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).
|
||||
//
|
||||
// This file is part of Spot, a model checking library.
|
||||
|
|
@ -38,8 +38,8 @@ namespace spot
|
|||
|
||||
state_union::~state_union()
|
||||
{
|
||||
delete left_;
|
||||
delete right_;
|
||||
left_->destroy();
|
||||
right_->destroy();
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -293,8 +293,8 @@ namespace spot
|
|||
right_acc_missing_,
|
||||
left_var_missing_,
|
||||
right_var_missing_);
|
||||
delete left_init;
|
||||
delete right_init;
|
||||
left_init->destroy();
|
||||
right_init->destroy();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -44,7 +44,8 @@ namespace spot
|
|||
virtual
|
||||
~state_wdba_comp_proxy()
|
||||
{
|
||||
delete s_;
|
||||
if (s_)
|
||||
s_->destroy();
|
||||
}
|
||||
|
||||
state*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue