summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/netlist/nl_factory.cpp
diff options
context:
space:
mode:
author couriersud <couriersud@arcor.de>2016-05-16 22:36:46 +0200
committer couriersud <couriersud@arcor.de>2016-05-21 12:58:23 +0200
commitd200744fbfb40fd5cd017c2222a44523f8ba12e6 (patch)
tree91281a8c3b55b5d12eaf622e5cd0a88550096430 /src/lib/netlist/nl_factory.cpp
parent17d85d78d1f50e3eeeb58a4f4a806ad5ea31d323 (diff)
Converted more devices to new layout. Improved memory handling in
factories. (nw)
Diffstat (limited to 'src/lib/netlist/nl_factory.cpp')
-rw-r--r--src/lib/netlist/nl_factory.cpp22
1 files changed, 8 insertions, 14 deletions
diff --git a/src/lib/netlist/nl_factory.cpp b/src/lib/netlist/nl_factory.cpp
index 940e0ae656d..cd351e89c9c 100644
--- a/src/lib/netlist/nl_factory.cpp
+++ b/src/lib/netlist/nl_factory.cpp
@@ -41,11 +41,6 @@ factory_list_t::factory_list_t( setup_t &setup)
factory_list_t::~factory_list_t()
{
- for (std::size_t i=0; i < size(); i++)
- {
- base_factory_t *p = value_at(i);
- pfree(p);
- }
clear();
}
@@ -71,21 +66,20 @@ void factory_list_t::error(const pstring &s)
m_setup.log().fatal("{1}", s);
}
-std::shared_ptr<device_t> factory_list_t::new_device_by_name(const pstring &devname, netlist_t &anetlist, const pstring &name)
+powned_ptr<device_t> factory_list_t::new_device_by_name(const pstring &devname, netlist_t &anetlist, const pstring &name)
{
base_factory_t *f = factory_by_name(devname);
- return std::shared_ptr<device_t>(f->Create(anetlist, name));
+ return f->Create(anetlist, name);
}
base_factory_t * factory_list_t::factory_by_name(const pstring &devname)
{
- if (contains(devname))
- return (*this)[devname];
- else
- {
- m_setup.log().fatal("Class {1} not found!\n", devname);
- return nullptr; // appease code analysis
- }
+ for (auto & e : *this)
+ if (e->name() == devname)
+ return e.get();
+
+ m_setup.log().fatal("Class {1} not found!\n", devname);
+ return nullptr; // appease code analysis
}
}