mirror of
https://github.com/holub/mame
synced 2025-04-22 08:22:15 +03:00
netlist: more memory allocation refactoring. (nw)
This commit is contained in:
parent
aad01d572a
commit
c5a513ca90
@ -453,7 +453,7 @@ netlist_base_factory_truthtable_t::netlist_base_factory_truthtable_t(const pstri
|
||||
|
||||
#define ENTRYY(n, m, s) case (n * 100 + m): \
|
||||
{ using xtype = netlist_factory_truthtable_t<n, m>; \
|
||||
ret = plib::palloc<xtype>(desc.name, desc.classname, desc.def_param, s); } break
|
||||
ret = plib::make_unique<xtype>(desc.name, desc.classname, desc.def_param, s); } break
|
||||
|
||||
#define ENTRY(n, s) ENTRYY(n, 1, s); ENTRYY(n, 2, s); ENTRYY(n, 3, s); \
|
||||
ENTRYY(n, 4, s); ENTRYY(n, 5, s); ENTRYY(n, 6, s); \
|
||||
@ -461,7 +461,7 @@ netlist_base_factory_truthtable_t::netlist_base_factory_truthtable_t(const pstri
|
||||
|
||||
void tt_factory_create(setup_t &setup, tt_desc &desc, const pstring &sourcefile)
|
||||
{
|
||||
netlist_base_factory_truthtable_t *ret;
|
||||
std::unique_ptr<netlist_base_factory_truthtable_t> ret;
|
||||
|
||||
switch (desc.ni * 100 + desc.no)
|
||||
{
|
||||
@ -484,7 +484,7 @@ void tt_factory_create(setup_t &setup, tt_desc &desc, const pstring &sourcefile)
|
||||
ret->m_desc = desc.desc;
|
||||
if (desc.family != "")
|
||||
ret->m_family = setup.family_from_model(desc.family);
|
||||
setup.factory().register_device(std::unique_ptr<netlist_base_factory_truthtable_t>(ret));
|
||||
setup.factory().register_device(std::move(ret));
|
||||
}
|
||||
|
||||
} //namespace devices
|
||||
|
@ -27,7 +27,7 @@
|
||||
static std::unique_ptr<factory::element_t> NETLIB_NAME(p_alias ## _c) \
|
||||
(const pstring &classname) \
|
||||
{ \
|
||||
return std::unique_ptr<factory::element_t>(plib::palloc<factory::device_element_t<ns :: NETLIB_NAME(chip)>>(p_name, classname, p_def_param, pstring(__FILE__))); \
|
||||
return plib::make_unique<factory::device_element_t<ns :: NETLIB_NAME(chip)>>(p_name, classname, p_def_param, pstring(__FILE__)); \
|
||||
} \
|
||||
\
|
||||
factory::constructor_ptr_t decl_ ## p_alias = NETLIB_NAME(p_alias ## _c);
|
||||
@ -101,7 +101,7 @@ namespace factory {
|
||||
void register_device(const pstring &name, const pstring &classname,
|
||||
const pstring &def_param)
|
||||
{
|
||||
register_device(std::unique_ptr<element_t>(plib::palloc<device_element_t<device_class>>(name, classname, def_param)));
|
||||
register_device(plib::make_unique<device_element_t<device_class>>(name, classname, def_param));
|
||||
}
|
||||
|
||||
void register_device(std::unique_ptr<element_t> &&factory);
|
||||
@ -128,7 +128,7 @@ namespace factory {
|
||||
std::unique_ptr<element_t> constructor_t(const pstring &name, const pstring &classname,
|
||||
const pstring &def_param)
|
||||
{
|
||||
return std::unique_ptr<element_t>(plib::palloc<device_element_t<T>>(name, classname, def_param));
|
||||
return plib::make_unique<device_element_t<T>>(name, classname, def_param);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -593,11 +593,12 @@ void setup_t::connect_terminals(detail::core_terminal_t &t1, detail::core_termin
|
||||
{
|
||||
log().debug("adding analog net ...\n");
|
||||
// FIXME: Nets should have a unique name
|
||||
auto anet = plib::palloc<analog_net_t>(netlist(),"net." + t1.name());
|
||||
netlist().register_net(plib::owned_ptr<analog_net_t>(anet, true));
|
||||
t1.set_net(anet);
|
||||
anet->add_terminal(t2);
|
||||
anet->add_terminal(t1);
|
||||
auto anet = plib::owned_ptr<analog_net_t>::Create(netlist(),"net." + t1.name());
|
||||
auto anetp = anet.get();
|
||||
netlist().register_net(std::move(anet));
|
||||
t1.set_net(anetp);
|
||||
anetp->add_terminal(t2);
|
||||
anetp->add_terminal(t1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -648,8 +649,6 @@ bool setup_t::connect_input_input(detail::core_terminal_t &t1, detail::core_term
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool setup_t::connect(detail::core_terminal_t &t1_in, detail::core_terminal_t &t2_in)
|
||||
{
|
||||
log().debug("Connecting {1} to {2}\n", t1_in.name(), t2_in.name());
|
||||
|
@ -100,7 +100,7 @@ void matrix_solver_t::setup_base(analog_net_t::list_t &nets)
|
||||
{
|
||||
m_nets.push_back(net);
|
||||
m_terms.push_back(plib::make_unique<terms_for_net_t>());
|
||||
m_rails_temp.push_back(plib::palloc<terms_for_net_t>());
|
||||
m_rails_temp.push_back(plib::make_unique<terms_for_net_t>());
|
||||
}
|
||||
|
||||
for (std::size_t k = 0; k < nets.size(); k++)
|
||||
@ -271,12 +271,12 @@ void matrix_solver_t::setup_matrix()
|
||||
m_terms[k]->set_pointers();
|
||||
}
|
||||
|
||||
for (terms_for_net_t *rt : m_rails_temp)
|
||||
for (auto &rt : m_rails_temp)
|
||||
{
|
||||
rt->clear(); // no longer needed
|
||||
plib::pfree(rt); // no longer needed
|
||||
}
|
||||
|
||||
// free all - no longer needed
|
||||
m_rails_temp.clear();
|
||||
|
||||
sort_terms(m_sort);
|
||||
|
@ -207,7 +207,7 @@ protected:
|
||||
std::vector<analog_net_t *> m_nets;
|
||||
std::vector<std::unique_ptr<proxied_analog_output_t>> m_inps;
|
||||
|
||||
std::vector<terms_for_net_t *> m_rails_temp;
|
||||
std::vector<std::unique_ptr<terms_for_net_t>> m_rails_temp;
|
||||
|
||||
const solver_parameters_t &m_params;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user