From 4f05917494b22943ab0e7c466e4eb9f7a5896daa Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Sat, 3 Oct 2020 02:50:49 +1000 Subject: Got rid of global_alloc/global_free. The global_alloc/global_free functions have outlived their usefulness. They don't allow consistently overriding the default memory allocation behaviour because they aren't used consistently, and we don't have standard library allocator wrappers for them that we'd need to use them consistently with all the standard library containers we're using. If you need to change the default allocator behaviour, you can override the new/delete operators, and there are ways to get more fine-grained control that way. We're already doing that to pre-fill memory in debug builds. Code was already starting to depend on global_alloc/global_free wrapping new/delete. For example some parts of the code (including the UI and Windows debugger) was putting the result of global_alloc in a std::unique_ptr wrappers without custom deleters, and the SPU sound device was assuming it could use global_free to release memory allocated with operator new. There was also code misunderstanding the behaviour of global_alloc, for example the GROM port cartridge code was checking for nullptr when a failure will actually throw std::bad_alloc. As well as substituting new/delete, I've made several things use smart pointers to reduce the chance of leaks, and fixed a couple of leaks, too. --- src/emu/addrmap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/emu/addrmap.cpp') diff --git a/src/emu/addrmap.cpp b/src/emu/addrmap.cpp index 61f7375d236..604e05ab864 100644 --- a/src/emu/addrmap.cpp +++ b/src/emu/addrmap.cpp @@ -873,7 +873,7 @@ void address_map::global_mask(offs_t mask) address_map_entry &address_map::operator()(offs_t start, offs_t end) { - address_map_entry *ptr = global_alloc(address_map_entry(*m_device, *this, start, end)); + address_map_entry *ptr = new address_map_entry(*m_device, *this, start, end); m_entrylist.append(*ptr); return *ptr; } -- cgit v1.2.3-70-g09d2