summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/netlist/plib/pstate.cpp
diff options
context:
space:
mode:
author couriersud <couriersud@arcor.de>2016-05-14 15:17:21 +0200
committer couriersud <couriersud@arcor.de>2016-05-16 12:41:20 +0200
commitf35ba3f5fdbc8394864863bca70d5b31fa582cfe (patch)
tree0b8f38c46f8a5d996333f989a9dc1c31a85e6d3d /src/lib/netlist/plib/pstate.cpp
parentef7d6d98d85fddd606f0237f2a4bfff1abeb81f5 (diff)
More automatic memory handling. (nw)
Diffstat (limited to 'src/lib/netlist/plib/pstate.cpp')
-rw-r--r--src/lib/netlist/plib/pstate.cpp24
1 files changed, 10 insertions, 14 deletions
diff --git a/src/lib/netlist/plib/pstate.cpp b/src/lib/netlist/plib/pstate.cpp
index d6ff433e388..aa5d7b7bae2 100644
--- a/src/lib/netlist/plib/pstate.cpp
+++ b/src/lib/netlist/plib/pstate.cpp
@@ -13,7 +13,7 @@ pstate_manager_t::pstate_manager_t()
pstate_manager_t::~pstate_manager_t()
{
- m_save.clear_and_free();
+ m_save.clear();
}
@@ -36,24 +36,20 @@ ATTR_COLD void pstate_manager_t::save_state_ptr(const pstring &stname, const pst
"DT_FLOAT"
};
- pstate_entry_t *p = palloc(pstate_entry_t(stname, dt, owner, size, count, ptr, is_ptr));
- m_save.push_back(p);
+ auto p = std::make_unique<pstate_entry_t>(stname, dt, owner, size, count, ptr, is_ptr);
+ m_save.push_back(std::move(p));
}
ATTR_COLD void pstate_manager_t::remove_save_items(const void *owner)
{
- pstate_entry_t::list_t todelete;
-
- for (std::size_t i=0; i < m_save.size(); i++)
+ unsigned i = 0;
+ while (i < m_save.size())
{
if (m_save[i]->m_owner == owner)
- todelete.push_back(m_save[i]);
- }
- for (std::size_t i=0; i < todelete.size(); i++)
- {
- m_save.remove(todelete[i]);
+ m_save.remove_at(i);
+ else
+ i++;
}
- todelete.clear_and_free();
}
ATTR_COLD void pstate_manager_t::pre_save()
@@ -74,7 +70,7 @@ template<> ATTR_COLD void pstate_manager_t::save_item(pstate_callback_t &state,
{
//save_state_ptr(stname, DT_CUSTOM, 0, 1, &state);
pstate_callback_t *state_p = &state;
- pstate_entry_t *p = palloc(pstate_entry_t(stname, owner, state_p));
- m_save.push_back(p);
+ auto p = std::make_unique<pstate_entry_t>(stname, owner, state_p);
+ m_save.push_back(std::move(p));
state.register_state(*this, stname);
}