Commit 51151ab2 authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz
Browse files

Handle all automata through shared_ptr. (monstro patch)

A type such as 'const tgba_digraph*' and 'tgba_digraph*' are replaced
by 'const_tgba_digraph_ptr' and 'tgba_digraph_ptr'.  Additionally 'new
tgba_digraph(...)' is replaced by 'make_tgba_digraph(...)'.

This convention is followed by all automata types. Those smart
pointers should normally be passed by const reference as input of
function to avoid the atomic increments/decrements, but I probably
missed a few, as this huge patch took me nearly 12h.

* src/kripke/fwd.hh, src/tgba/fwd.hh: New files.
* src/kripke/Makefile.am, src/tgba/Makefile.am: Adjust.
* iface/dve2/dve2.cc, iface/dve2/dve2.hh, iface/dve2/dve2check.cc,
src/bin/common_output.hh, src/bin/dstar2tgba.cc,
src/bin/ltl2tgba.cc, src/bin/ltl2tgta.cc, src/bin/ltlcross.cc,
src/bin/ltlfilt.cc, src/dstarparse/dra2ba.cc,
src/dstarparse/dstar2tgba.cc, src/dstarparse/dstarparse.yy,
src/dstarparse/nra2nba.cc, src/dstarparse/nsa2tgba.cc,
src/dstarparse/public.hh, src/graphtest/tgbagraph.cc,
src/kripke/fairkripke.hh, src/kripke/kripke.hh,
src/kripke/kripkeexplicit.cc, src/kripke/kripkeexplicit.hh,
src/kripke/kripkeprint.cc, src/kripke/kripkeprint.hh,
src/kripkeparse/kripkeparse.yy, src/kripkeparse/public.hh,
src/kripketest/parse_print_test.cc, src/ltlvisit/apcollect.cc,
src/ltlvisit/apcollect.hh, src/ltlvisit/contain.cc,
src/ltlvisit/contain.hh, src/neverparse/neverclaimparse.yy,
src/neverparse/public.hh, src/priv/accmap.hh,
src/priv/countstates.cc, src/priv/countstates.hh, src/saba/saba.hh,
src/saba/sabacomplementtgba.cc, src/saba/sabacomplementtgba.hh,
src/sabaalgos/sabadotty.cc, src/sabaalgos/sabadotty.hh,
src/sabaalgos/sabareachiter.cc, src/sabaalgos/sabareachiter.hh,
src/sabatest/sabacomplementtgba.cc, src/ta/ta.hh,
src/ta/taexplicit.cc, src/ta/taexplicit.hh, src/ta/taproduct.cc,
src/ta/taproduct.hh, src/ta/tgta.hh, src/ta/tgtaexplicit.cc,
src/ta/tgtaexplicit.hh, src/ta/tgtaproduct.cc,
src/ta/tgtaproduct.hh, src/taalgos/dotty.cc, src/taalgos/dotty.hh,
src/taalgos/emptinessta.cc, src/taalgos/emptinessta.hh,
src/taalgos/minimize.cc, src/taalgos/minimize.hh,
src/taalgos/reachiter.cc, src/taalgos/reachiter.hh,
src/taalgos/statessetbuilder.cc, src/taalgos/statessetbuilder.hh,
src/taalgos/stats.cc, src/taalgos/stats.hh, src/taalgos/tgba2ta.cc,
src/taalgos/tgba2ta.hh, src/tgba/bdddict.cc, src/tgba/bdddict.hh,
src/tgba/formula2bdd.hh, src/tgba/futurecondcol.cc,
src/tgba/futurecondcol.hh, src/tgba/taatgba.hh, src/tgba/tgba.cc,
src/tgba/tgba.hh, src/tgba/tgbagraph.hh,
src/tgba/tgbakvcomplement.cc, src/tgba/tgbakvcomplement.hh,
src/tgba/tgbamask.cc, src/tgba/tgbamask.hh, src/tgba/tgbaproduct.cc,
src/tgba/tgbaproduct.hh, src/tgba/tgbaproxy.cc,
src/tgba/tgbaproxy.hh, src/tgba/tgbasafracomplement.cc,
src/tgba/tgbasafracomplement.hh, src/tgba/tgbascc.cc,
src/tgba/tgbascc.hh, src/tgba/tgbasgba.cc, src/tgba/tgbasgba.hh,
src/tgba/wdbacomp.cc, src/tgba/wdbacomp.hh,
src/tgbaalgos/bfssteps.cc, src/tgbaalgos/bfssteps.hh,
src/tgbaalgos/complete.cc, src/tgbaalgos/complete.hh,
src/tgbaalgos/compsusp.cc, src/tgbaalgos/compsusp.hh,
src/tgbaalgos/cycles.hh, src/tgbaalgos/degen.cc,
src/tgbaalgos/degen.hh, src/tgbaalgos/dotty.cc,
src/tgbaalgos/dotty.hh, src/tgbaalgos/dottydec.cc,
src/tgbaalgos/dottydec.hh, src/tgbaalgos/dtbasat.cc,
src/tgbaalgos/dtbasat.hh, src/tgbaalgos/dtgbacomp.cc,
src/tgbaalgos/dtgbacomp.hh, src/tgbaalgos/dtgbasat.cc,
src/tgbaalgos/dtgbasat.hh, src/tgbaalgos/dupexp.cc,
src/tgbaalgos/dupexp.hh, src/tgbaalgos/emptiness.cc,
src/tgbaalgos/emptiness.hh, src/tgbaalgos/gtec/gtec.cc,
src/tgbaalgos/gtec/gtec.hh, src/tgbaalgos/gtec/status.cc,
src/tgbaalgos/gtec/status.hh, src/tgbaalgos/gv04.cc,
src/tgbaalgos/gv04.hh, src/tgbaalgos/isdet.cc,
src/tgbaalgos/isdet.hh, src/tgbaalgos/isweakscc.cc,
src/tgbaalgos/lbtt.cc, src/tgbaalgos/lbtt.hh,
src/tgbaalgos/ltl2taa.cc, src/tgbaalgos/ltl2taa.hh,
src/tgbaalgos/ltl2tgba_fm.cc, src/tgbaalgos/ltl2tgba_fm.hh,
src/tgbaalgos/magic.cc, src/tgbaalgos/magic.hh,
src/tgbaalgos/minimize.cc, src/tgbaalgos/minimize.hh,
src/tgbaalgos/ndfs_result.hxx, src/tgbaalgos/neverclaim.cc,
src/tgbaalgos/neverclaim.hh, src/tgbaalgos/postproc.cc,
src/tgbaalgos/postproc.hh, src/tgbaalgos/powerset.cc,
src/tgbaalgos/powerset.hh, src/tgbaalgos/projrun.cc,
src/tgbaalgos/projrun.hh, src/tgbaalgos/randomgraph.cc,
src/tgbaalgos/randomgraph.hh, src/tgbaalgos/reachiter.cc,
src/tgbaalgos/reachiter.hh, src/tgbaalgos/reducerun.cc,
src/tgbaalgos/reducerun.hh, src/tgbaalgos/replayrun.cc,
src/tgbaalgos/replayrun.hh, src/tgbaalgos/rundotdec.cc,
src/tgbaalgos/rundotdec.hh, src/tgbaalgos/safety.cc,
src/tgbaalgos/safety.hh, src/tgbaalgos/save.cc,
src/tgbaalgos/save.hh, src/tgbaalgos/scc.cc, src/tgbaalgos/scc.hh,
src/tgbaalgos/sccfilter.cc, src/tgbaalgos/sccfilter.hh,
src/tgbaalgos/sccinfo.cc, src/tgbaalgos/sccinfo.hh,
src/tgbaalgos/se05.cc, src/tgbaalgos/se05.hh,
src/tgbaalgos/simulation.cc, src/tgbaalgos/simulation.hh,
src/tgbaalgos/stats.cc, src/tgbaalgos/stats.hh,
src/tgbaalgos/stripacc.cc, src/tgbaalgos/stripacc.hh,
src/tgbaalgos/tau03.cc, src/tgbaalgos/tau03.hh,
src/tgbaalgos/tau03opt.cc, src/tgbaalgos/tau03opt.hh,
src/tgbaalgos/translate.cc, src/tgbaalgos/translate.hh,
src/tgbaparse/public.hh, src/tgbaparse/tgbaparse.yy,
src/tgbatest/complementation.cc, src/tgbatest/explprod.cc,
src/tgbatest/ltl2tgba.cc, src/tgbatest/ltlprod.cc,
src/tgbatest/maskacc.cc, src/tgbatest/powerset.cc,
src/tgbatest/randtgba.cc, src/tgbatest/taatgba.cc,
src/tgbatest/tgbaread.cc, src/tgbatest/tripprod.cc,
wrap/python/ajax/spot.in, wrap/python/spot.i,
wrap/python/tests/interdep.py: Use shared pointers for automata.
parent ca85d418
......@@ -997,7 +997,7 @@ namespace spot
}
kripke*
kripke_ptr
load_dve2(const std::string& file_arg, bdd_dict_ptr dict,
const ltl::atomic_prop_set* to_observe,
const ltl::formula* dead,
......@@ -1112,6 +1112,6 @@ namespace spot
return 0;
}
return new dve2_kripke(d, dict, ps, dead, compress);
return std::make_shared<dve2_kripke>(d, dict, ps, dead, compress);
}
}
......@@ -56,7 +56,7 @@ namespace spot
// \a dead an atomic proposition or constant to use for looping on
// dead states
// \a verbose whether to output verbose messages
SPOT_API kripke*
SPOT_API kripke_ptr
load_dve2(const std::string& file, bdd_dict_ptr dict,
const ltl::atomic_prop_set* to_observe,
const ltl::formula* dead = ltl::constant::true_instance(),
......
......@@ -62,7 +62,7 @@ Options:\n\
}
int
main(int argc, char **argv)
checked_main(int argc, char **argv)
{
spot::timer_map tm;
......@@ -157,14 +157,14 @@ main(int argc, char **argv)
spot::ltl::atomic_prop_set ap;
auto dict = spot::make_bdd_dict();
spot::kripke* model = 0;
const spot::tgba* prop = 0;
spot::tgba* product = 0;
spot::const_kripke_ptr model = 0;
spot::const_tgba_ptr prop = 0;
spot::const_tgba_ptr product = 0;
spot::emptiness_check_instantiator* echeck_inst = 0;
int exit_code = 0;
const spot::ltl::formula* f = 0;
const spot::ltl::formula* deadf = 0;
spot::postprocessor post;
const spot::ltl::formula* deadf = 0;
const spot::ltl::formula* f = 0;
if (dead == 0 || !strcasecmp(dead, "true"))
{
......@@ -252,7 +252,7 @@ main(int argc, char **argv)
goto safe_exit;
}
product = new spot::tgba_product(model, prop);
product = spot::product(model, prop);
if (output == DotProduct)
{
......@@ -362,9 +362,6 @@ main(int argc, char **argv)
safe_exit:
delete echeck_inst;
delete product;
delete prop;
delete model;
if (f)
f->destroy();
......@@ -373,15 +370,24 @@ main(int argc, char **argv)
if (use_timer)
tm.print(std::cout);
tm.reset_all(); // This helps valgrind.
return exit_code;
}
int
main(int argc, char **argv)
{
auto exit_code = checked_main(argc, argv);
// Additional checks to debug reference counts in formulas.
spot::ltl::atomic_prop::dump_instances(std::cerr);
spot::ltl::unop::dump_instances(std::cerr);
spot::ltl::binop::dump_instances(std::cerr);
spot::ltl::multop::dump_instances(std::cerr);
spot::ltl::bunop::dump_instances(std::cerr);
assert(spot::ltl::atomic_prop::instance_count() == 0);
assert(spot::ltl::unop::instance_count() == 0);
assert(spot::ltl::binop::instance_count() == 0);
assert(spot::ltl::multop::instance_count() == 0);
assert(spot::ltl::bunop::instance_count() == 0);
exit(exit_code);
}
// -*- coding: utf-8 -*-
// Copyright (C) 2012, 2013 Laboratoire de Recherche et Développement
// Copyright (C) 2012, 2013, 2014 Laboratoire de Recherche et Développement
// de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
......@@ -73,7 +73,8 @@ public:
}
std::ostream&
print(const spot::tgba* aut, const spot::ltl::formula* f = 0,
print(const spot::const_tgba_ptr& aut,
const spot::ltl::formula* f = 0,
double run_time = -1.)
{
formula_ = f;
......
......@@ -224,7 +224,8 @@ namespace
/// The \a f argument is not needed if the Formula does not need
/// to be output.
std::ostream&
print(const spot::dstar_aut* daut, const spot::tgba* aut,
print(const spot::const_dstar_aut_ptr& daut,
const spot::const_tgba_ptr& aut,
const char* filename, double run_time)
{
filename_ = filename;
......@@ -292,17 +293,11 @@ namespace
process_file(const char* filename)
{
spot::dstar_parse_error_list pel;
spot::dstar_aut* daut;
daut = spot::dstar_parse(filename, pel, spot::make_bdd_dict());
auto daut = spot::dstar_parse(filename, pel, spot::make_bdd_dict());
if (spot::format_dstar_parse_errors(std::cerr, filename, pel))
{
delete daut;
return 2;
}
return 2;
if (!daut)
{
error(2, 0, "failed to read automaton from %s", filename);
}
error(2, 0, "failed to read automaton from %s", filename);
const xtime_t before = gethrxtime();
......@@ -336,8 +331,6 @@ namespace
statistics.print(daut, aut, filename, conversion_time) << '\n';
break;
}
delete aut;
delete daut;
flush_cout();
return 0;
}
......
......@@ -214,7 +214,7 @@ namespace
const char* filename = 0, int linenum = 0)
{
const xtime_t before = gethrxtime();
const spot::tgba* aut = trans.run(&f);
auto aut = trans.run(&f);
const xtime_t after = gethrxtime();
const double prec = XTIME_PRECISION;
const double translation_time = (after - before) / prec;
......@@ -254,7 +254,6 @@ namespace
statistics.print(aut, f, translation_time) << '\n';
break;
}
delete aut;
f->destroy();
flush_cout();
return 0;
......
......@@ -171,7 +171,7 @@ namespace
process_formula(const spot::ltl::formula* f,
const char* filename = 0, int linenum = 0)
{
const spot::tgba* aut = trans.run(&f);
auto aut = trans.run(&f);
// This should not happen, because the parser we use can only
// read PSL/LTL formula, but since our ltl::formula* type can
......@@ -189,36 +189,22 @@ namespace
if (ta_type != TGTA)
{
spot::ta* testing_automaton =
auto testing_automaton =
tgba_to_ta(aut, ap_set, type == spot::postprocessor::BA,
opt_with_artificial_initial_state,
opt_single_pass_emptiness_check,
opt_with_artificial_livelock);
if (level != spot::postprocessor::Low)
{
spot::ta* testing_automaton_nm = testing_automaton;
testing_automaton = spot::minimize_ta(testing_automaton);
delete testing_automaton_nm;
}
testing_automaton = spot::minimize_ta(testing_automaton);
spot::dotty_reachable(std::cout, testing_automaton);
delete testing_automaton;
}
else
{
spot::tgta_explicit* tgta = tgba_to_tgta(aut, ap_set);
auto tgta = tgba_to_tgta(aut, ap_set);
if (level != spot::postprocessor::Low)
{
spot::tgta_explicit* a = spot::minimize_tgta(tgta);
delete tgta;
tgta = a;
}
spot::dotty_reachable(std::cout,
dynamic_cast<spot::tgta_explicit*>(tgta)
->get_ta());
delete tgta;
tgta = spot::minimize_tgta(tgta);
spot::dotty_reachable(std::cout, tgta->get_ta());
}
delete aut;
f->destroy();
flush_cout();
return 0;
......
......@@ -848,7 +848,7 @@ namespace
string_to_tmp(string_ltl_wring, serial, filename_ltl_wring);
}
const spot::tgba*
spot::const_tgba_ptr
translate(unsigned int translator_num, char l, statistics_formula* fstats)
{
output.reset(translator_num);
......@@ -867,7 +867,7 @@ namespace
const char* status_str = 0;
const spot::tgba* res = 0;
spot::const_tgba_ptr res = 0;
if (timed_out)
{
// This is not considered to be a global error.
......@@ -911,8 +911,7 @@ namespace
err << "error: failed to parse the produced neverclaim.\n";
spot::format_neverclaim_parse_errors(err, filename, pel);
end_error();
delete res;
res = 0;
res = nullptr;
}
break;
}
......@@ -947,8 +946,7 @@ namespace
{
spot::dstar_parse_error_list pel;
std::string filename = output.val()->name();
spot::dstar_aut* aut;
aut = spot::dstar_parse(filename, pel, dict);
auto aut = spot::dstar_parse(filename, pel, dict);
if (!pel.empty())
{
status_str = "parse error";
......@@ -958,8 +956,7 @@ namespace
" output.\n";
spot::format_dstar_parse_errors(err, filename, pel);
end_error();
delete aut;
res = 0;
res = nullptr;
}
else
{
......@@ -992,7 +989,6 @@ namespace
}
// convert it into TGBA for further processing
res = dstar_to_tgba(aut);
delete aut;
}
break;
}
......@@ -1049,10 +1045,11 @@ namespace
};
static void
check_empty_prod(const spot::tgba* aut_i, const spot::tgba* aut_j,
check_empty_prod(const spot::const_tgba_ptr& aut_i,
const spot::const_tgba_ptr& aut_j,
size_t i, size_t j, bool icomp, bool jcomp)
{
spot::tgba_product* prod = new spot::tgba_product(aut_i, aut_j);
auto prod = spot::product(aut_i, aut_j);
spot::emptiness_check* ec = spot::couvreur99(prod);
spot::emptiness_check_result* res = ec->check();
......@@ -1090,7 +1087,6 @@ namespace
}
delete res;
delete ec;
delete prod;
}
static void
......@@ -1154,16 +1150,18 @@ namespace
// Collect all the states of SSPACE that appear in the accepting SCCs
// of PROD.
static void
states_in_acc(const spot::scc_map* m, const spot::tgba* sspace,
states_in_acc(const spot::scc_map* m,
const spot::const_tgba_ptr& sspace,
state_set& s)
{
const spot::tgba* aut = m->get_aut();
auto aut = m->get_aut();
unsigned c = m->scc_count();
for (unsigned n = 0; n < c; ++n)
if (m->accepting(n))
for (auto i: m->states_of(n))
{
spot::state* x = aut->project_state(i, sspace);
assert(x);
if (!s.insert(x).second)
x->destroy();
}
......@@ -1171,7 +1169,7 @@ namespace
static bool
consistency_check(const spot::scc_map* pos, const spot::scc_map* neg,
const spot::tgba* sspace)
const spot::const_tgba_ptr& sspace)
{
// the states of SSPACE should appear in the accepting SCC of at
// least one of POS or NEG. Maybe both.
......@@ -1266,12 +1264,12 @@ namespace
// These store the result of the translation of the positive and
// negative formulas.
size_t m = translators.size();
std::vector<const spot::tgba*> pos(m);
std::vector<const spot::tgba*> neg(m);
std::vector<spot::const_tgba_ptr> pos(m);
std::vector<spot::const_tgba_ptr> neg(m);
// These store the complement of the above results, when we can
// compute it easily.
std::vector<const spot::tgba*> comp_pos(m);
std::vector<const spot::tgba*> comp_neg(m);
std::vector<spot::const_tgba_ptr> comp_pos(m);
std::vector<spot::const_tgba_ptr> comp_neg(m);
unsigned n = vstats.size();
......@@ -1400,20 +1398,19 @@ namespace
{
// build a random state-space.
spot::srand(seed);
spot::tgba* statespace = spot::random_graph(states, density,
ap, dict);
auto statespace = spot::random_graph(states, density, ap, dict);
// Products of the state space with the positive automata.
std::vector<spot::tgba*> pos_prod(m);
std::vector<spot::const_tgba_ptr> pos_prod(m);
// Products of the state space with the negative automata.
std::vector<spot::tgba*> neg_prod(m);
std::vector<spot::const_tgba_ptr> neg_prod(m);
// Associated SCC maps.
std::vector<spot::scc_map*> pos_map(m);
std::vector<spot::scc_map*> neg_map(m);
for (size_t i = 0; i < m; ++i)
if (pos[i])
{
spot::tgba* p = new spot::tgba_product(pos[i], statespace);
auto p = spot::product(pos[i], statespace);
pos_prod[i] = p;
spot::scc_map* sm = new spot::scc_map(p);
sm->build_map();
......@@ -1433,7 +1430,7 @@ namespace
for (size_t i = 0; i < m; ++i)
if (neg[i])
{
spot::tgba* p = new spot::tgba_product(neg[i], statespace);
auto p = spot::product(neg[i], statespace);
neg_prod[i] = p;
spot::scc_map* sm = new spot::scc_map(p);
sm->build_map();
......@@ -1475,31 +1472,14 @@ namespace
// Cleanup.
if (!no_checks)
for (size_t i = 0; i < m; ++i)
{
delete neg_map[i];
delete neg_prod[i];
}
delete neg_map[i];
for (size_t i = 0; i < m; ++i)
{
delete pos_map[i];
delete pos_prod[i];
}
delete statespace;
delete pos_map[i];
++seed;
}
std::cerr << std::endl;
delete ap;
if (!no_checks)
for (size_t i = 0; i < m; ++i)
{
delete neg[i];
delete comp_neg[i];
delete comp_pos[i];
}
for (size_t i = 0; i < m; ++i)
delete pos[i];
// Shall we stop processing formulas now?
abort_run = global_error_flag && stop_on_error;
return 0;
......
......@@ -560,9 +560,7 @@ namespace
{
matched &= !guarantee || is_guarantee_automaton(min);
matched &= !safety || is_safety_mwdba(min);
delete min;
}
delete aut;
}
matched ^= invert;
......
......@@ -48,7 +48,8 @@ namespace spot
// This function is defined in nra2nba.cc, and used only here.
SPOT_LOCAL
tgba_digraph* nra_to_nba(const dstar_aut* nra, const tgba* aut);
tgba_digraph_ptr nra_to_nba(const const_dstar_aut_ptr& nra,
const const_tgba_ptr& aut);
namespace
{
......@@ -63,15 +64,15 @@ namespace spot
// retrive acceptances.
static bool
filter_states(const tgba* aut,
const dstar_aut* dra,
filter_states(const const_tgba_ptr& aut,
const const_dstar_aut_ptr& dra,
const state_list& sl,
state_list& final,
state_list& nonfinal);
static bool
filter_scc(const tgba* aut,
const dstar_aut* dra,
filter_scc(const const_tgba_ptr& aut,
const const_dstar_aut_ptr& dra,
state_list& final,
state_list& nonfinal)
{
......@@ -97,8 +98,8 @@ namespace spot
}
static bool
filter_states(const tgba* aut,
const dstar_aut* dra,
filter_states(const const_tgba_ptr& aut,
const const_dstar_aut_ptr& dra,
const state_list& sl,
state_list& final,
state_list& nonfinal)
......@@ -146,15 +147,11 @@ namespace spot
// could be improved.
{
state_set keep(sl.begin(), sl.end());
const tgba* masked =
build_tgba_mask_keep(dra->aut, keep, sl.front());
const tgba* nba = nra_to_nba(dra, masked);
emptiness_check* ec = couvreur99(nba);
auto masked = build_tgba_mask_keep(dra->aut, keep, sl.front());
emptiness_check* ec = couvreur99(nra_to_nba(dra, masked));
emptiness_check_result* ecr = ec->check();
delete ecr;
delete ec;
delete nba;
delete masked;
if (ecr)
{
// This SCC is not DBA-realizable.
......@@ -197,13 +194,11 @@ namespace spot
//std::cerr << "unknown\n";
// Build a sub-automaton for just the unknown states,
// starting from any state in the SCC.
const tgba* scc_mask =
build_tgba_mask_keep(aut, unknown, *unknown.begin());
auto scc_mask = build_tgba_mask_keep(aut, unknown, *unknown.begin());
state_list local_final;
state_list local_nonfinal;
bool dbarealizable =
filter_scc(scc_mask, dra, local_final, local_nonfinal);
delete scc_mask;
if (!dbarealizable)
return false;
for (state_list::const_iterator i = local_final.begin();
......@@ -223,13 +218,13 @@ namespace spot
class dra_to_ba_worker: public tgba_reachable_iterator_depth_first
{
public:
dra_to_ba_worker(const dstar_aut* a,
dra_to_ba_worker(const const_dstar_aut_ptr& a,
const state_set& final,
const scc_map& sm,
const std::vector<bool>& realizable):
tgba_reachable_iterator_depth_first(a->aut),
in_(a),
out_(new tgba_digraph(a->aut->get_dict())),
out_(make_tgba_digraph(a->aut->get_dict())),
final_(final),
num_states_(a->aut->num_states()),
sm_(sm),
......@@ -242,7 +237,7 @@ namespace spot
out_->set_init_state(a->aut->get_init_state_number());
}
tgba_digraph*
tgba_digraph_ptr
result()
{
return out_;
......@@ -301,8 +296,8 @@ namespace spot
}
protected:
const dstar_aut* in_;
tgba_digraph* out_;
const const_dstar_aut_ptr& in_;
tgba_digraph_ptr out_;
const state_set& final_;
size_t num_states_;
bdd acc_;
......@@ -313,7 +308,7 @@ namespace spot
}
tgba_digraph* dra_to_ba(const dstar_aut* dra, bool* dba)
tgba_digraph_ptr dra_to_ba(const const_dstar_aut_ptr& dra, bool* dba)
{
assert(dra->type == Rabin);
......@@ -358,10 +353,7 @@ namespace spot
state_set fs(final.begin(), final.end());
dra_to_ba_worker w(dra, fs, sm, realizable);
w.run();
auto res1 = w.result();
auto res2 = scc_filter_states(res1);
delete res1;
return res2;
return scc_filter_states(w.result());
}
}
......@@ -21,8 +21,8 @@
namespace spot
{
tgba_digraph*
dstar_to_tgba(const dstar_aut* daut)
tgba_digraph_ptr
dstar_to_tgba(const const_dstar_aut_ptr& daut)
{
switch (daut->type)
{
......
......@@ -38,7 +38,7 @@
struct result_
{
spot::dstar_aut* d;
spot::dstar_aut_ptr d;
spot::ltl::environment* env;
std::vector<bdd> guards;
std::vector<bdd>::const_iterator cur_guard;
......@@ -143,8 +143,7 @@ header: auttype opt_eols V2 opt_eols EXPLICIT opt_eols sizes
}
if (err)
{
delete result.d->aut;
result.d->aut = 0;
result.d->aut = nullptr;
YYABORT;
}
result.d->aut->new_states(result.state_count);;
......@@ -313,10 +312,10 @@ dstaryy::parser::error(const location_type& location,
namespace spot
{
dstar_aut*
dstar_aut_ptr
dstar_parse(const std::string& name,
dstar_parse_error_list& error_list,
bdd_dict_ptr dict,
const bdd_dict_ptr& dict,
ltl::environment& env,
bool debug)
{
......@@ -327,8 +326,8 @@ namespace spot
return 0;
}
result_ r;
r.d = new dstar_aut;
r.d->aut = new tgba_digraph(dict);
r.d = std::make_shared<spot::dstar_aut>();
r.d->aut = make_tgba_digraph(dict);
r.d->accsets = 0;
r.env = &env;
dstaryy::parser parser(error_list, r);
......@@ -337,10 +336,7 @@ namespace spot
dstaryyclose();
if (!r.d->aut || !r.d->accsets)
{
delete r.d;
return 0;
}
return nullptr;
return r.d;
}
}
......
......@@ -38,9 +38,9 @@ namespace spot
// AUT is the automate we iterate on, while A is the automaton