diff options
author | 2010-09-07 04:51:51 +0000 | |
---|---|---|
committer | 2010-09-07 04:51:51 +0000 | |
commit | 7e98d6e5838de083aa70b1989341d31081f5325a (patch) | |
tree | 48977366b9a6ba9b0b619a704234b335b2506c90 | |
parent | 2dbd6f67f8f2cae2b51a3037ca37529bde22752d (diff) |
Put the state list in a simple_list<>.
-rw-r--r-- | src/emu/devcpu.c | 2 | ||||
-rw-r--r-- | src/emu/distate.c | 11 | ||||
-rw-r--r-- | src/emu/distate.h | 5 |
3 files changed, 8 insertions, 10 deletions
diff --git a/src/emu/devcpu.c b/src/emu/devcpu.c index ac5fe4d6379..eebe865f0c9 100644 --- a/src/emu/devcpu.c +++ b/src/emu/devcpu.c @@ -263,7 +263,7 @@ void legacy_cpu_device::device_start() m_inited = true; // fetch information about the CPU states - if (m_state_list == NULL) + if (m_state_list.count() == 0) { m_using_legacy_state = true; for (int index = 0; index < MAX_REGS; index++) diff --git a/src/emu/distate.c b/src/emu/distate.c index 29af7a88e5c..8749a557cde 100644 --- a/src/emu/distate.c +++ b/src/emu/distate.c @@ -410,8 +410,7 @@ device_config_state_interface::~device_config_state_interface() device_state_interface::device_state_interface(running_machine &machine, const device_config &config, device_t &device) : device_interface(machine, config, device), m_machine(machine), - m_state_config(dynamic_cast<const device_config_state_interface &>(config)), - m_state_list(NULL) + m_state_config(dynamic_cast<const device_config_state_interface &>(config)) { memset(m_fast_state, 0, sizeof(m_fast_state)); } @@ -584,9 +583,7 @@ device_state_entry &device_state_interface::state_add(int index, const char *sym device_state_entry *entry = auto_alloc(&m_machine, device_state_entry(index, symbol, data, size)); // append to the end of the list - device_state_entry **tailptr; - for (tailptr = &m_state_list; *tailptr != NULL; tailptr = &(*tailptr)->m_next) ; - *tailptr = entry; + m_state_list.append(*entry); // set the fast entry if applicable if (index >= k_fast_state_min && index <= k_fast_state_max) @@ -608,7 +605,7 @@ const device_state_entry *device_state_interface::state_find_entry(int index) return m_fast_state[index - k_fast_state_min]; // otherwise, scan the first - for (const device_state_entry *entry = m_state_list; entry != NULL; entry = entry->m_next) + for (const device_state_entry *entry = m_state_list.first(); entry != NULL; entry = entry->m_next) if (entry->m_index == index) return entry; @@ -625,6 +622,6 @@ const device_state_entry *device_state_interface::state_find_entry(int index) void device_state_interface::interface_post_start() { // make sure we got something during startup - if (m_state_list == NULL) + if (m_state_list.count() == 0) throw emu_fatalerror("No state registered for device '%s' that supports it!", m_device.tag()); } diff --git a/src/emu/distate.h b/src/emu/distate.h index 359beea187c..3328b66b947 100644 --- a/src/emu/distate.h +++ b/src/emu/distate.h @@ -73,6 +73,7 @@ enum class device_state_entry { friend class device_state_interface; + friend class simple_list<device_state_entry>; private: // construction/destruction @@ -161,7 +162,7 @@ public: // configuration access const device_config_state_interface &state_config() const { return m_state_config; } - const device_state_entry *state_first() const { return m_state_list; } + const device_state_entry *state_first() const { return m_state_list.first(); } // state getters UINT64 state(int index); @@ -205,7 +206,7 @@ protected: // state running_machine & m_machine; // reference to owning machine const device_config_state_interface & m_state_config; // reference to configuration data - device_state_entry * m_state_list; // head of state list + simple_list<device_state_entry> m_state_list; // head of state list device_state_entry * m_fast_state[k_fast_state_max + 1 - k_fast_state_min]; // fast access to common entries }; |