summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/emualloc.h
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2011-03-10 07:06:21 +0000
committer Aaron Giles <aaron@aarongiles.com>2011-03-10 07:06:21 +0000
commit46550a475b3efb3dacd58e3df8635f41dfa9b0c4 (patch)
tree0016c61619706bff7cb43f7a73079eb341470492 /src/emu/emualloc.h
parentd49ead22c9f89d8804dc03b6db7a63a2abc0019a (diff)
Non-debug builds need to free those memory_entries. Fixes enormous
memory consumption when iterating through all drivers like -romident does. Also moved softlist scanning into the main loop so that machine_configs are only constructed once.
Diffstat (limited to 'src/emu/emualloc.h')
-rw-r--r--src/emu/emualloc.h226
1 files changed, 113 insertions, 113 deletions
diff --git a/src/emu/emualloc.h b/src/emu/emualloc.h
index 10aa43a04e6..0a26fcad3ec 100644
--- a/src/emu/emualloc.h
+++ b/src/emu/emualloc.h
@@ -67,13 +67,125 @@
//**************************************************************************
-// TYPE DEFINITIONS
+// FUNCTION PROTOTYPES
+//**************************************************************************
+
+// allocate memory with file and line number information
+void *malloc_file_line(size_t size, const char *file, int line);
+
+// free memory with file and line number information
+void free_file_line(void *memory, const char *file, int line);
+
+// called from the exit path of any code that wants to check for unfreed memory
+void dump_unfreed_mem();
+
+
+
+//**************************************************************************
+// INLINE FUNCTIONS
//**************************************************************************
// zeromem_t is a dummy class used to tell new to zero memory after allocation
class zeromem_t { };
+// standard new/delete operators (try to avoid using)
+ATTR_FORCE_INLINE inline void *operator new(std::size_t size) throw (std::bad_alloc)
+{
+ void *result = malloc_file_line(size, NULL, 0);
+ if (result == NULL)
+ throw std::bad_alloc();
+ return result;
+}
+
+ATTR_FORCE_INLINE inline void *operator new[](std::size_t size) throw (std::bad_alloc)
+{
+ void *result = malloc_file_line(size, NULL, 0);
+ if (result == NULL)
+ throw std::bad_alloc();
+ return result;
+}
+
+ATTR_FORCE_INLINE inline void operator delete(void *ptr) throw()
+{
+ if (ptr != NULL)
+ free_file_line(ptr, NULL, 0);
+}
+
+ATTR_FORCE_INLINE inline void operator delete[](void *ptr) throw()
+{
+ if (ptr != NULL)
+ free_file_line(ptr, NULL, 0);
+}
+
+
+// file/line new/delete operators
+ATTR_FORCE_INLINE inline void *operator new(std::size_t size, const char *file, int line) throw (std::bad_alloc)
+{
+ void *result = malloc_file_line(size, file, line);
+ if (result == NULL)
+ throw std::bad_alloc();
+ return result;
+}
+
+ATTR_FORCE_INLINE inline void *operator new[](std::size_t size, const char *file, int line) throw (std::bad_alloc)
+{
+ void *result = malloc_file_line(size, file, line);
+ if (result == NULL)
+ throw std::bad_alloc();
+ return result;
+}
+
+ATTR_FORCE_INLINE inline void operator delete(void *ptr, const char *file, int line)
+{
+ if (ptr != NULL)
+ free_file_line(ptr, file, line);
+}
+
+ATTR_FORCE_INLINE inline void operator delete[](void *ptr, const char *file, int line)
+{
+ if (ptr != NULL)
+ free_file_line(ptr, file, line);
+}
+
+
+// file/line new/delete operators with zeroing
+ATTR_FORCE_INLINE inline void *operator new(std::size_t size, const char *file, int line, const zeromem_t &) throw (std::bad_alloc)
+{
+ void *result = malloc_file_line(size, file, line);
+ if (result == NULL)
+ throw std::bad_alloc();
+ memset(result, 0, size);
+ return result;
+}
+
+ATTR_FORCE_INLINE inline void *operator new[](std::size_t size, const char *file, int line, const zeromem_t &) throw (std::bad_alloc)
+{
+ void *result = malloc_file_line(size, file, line);
+ if (result == NULL)
+ throw std::bad_alloc();
+ memset(result, 0, size);
+ return result;
+}
+
+ATTR_FORCE_INLINE inline void operator delete(void *ptr, const char *file, int line, const zeromem_t &)
+{
+ if (ptr != NULL)
+ free_file_line(ptr, file, line);
+}
+
+ATTR_FORCE_INLINE inline void operator delete[](void *ptr, const char *file, int line, const zeromem_t &)
+{
+ if (ptr != NULL)
+ free_file_line(ptr, file, line);
+}
+
+
+
+//**************************************************************************
+// TYPE DEFINITIONS
+//**************************************************************************
+
// resource_pool_item is a base class for items that are tracked by a resource pool
class resource_pool_item
{
@@ -185,118 +297,6 @@ extern const zeromem_t zeromem;
//**************************************************************************
-// FUNCTION PROTOTYPES
-//**************************************************************************
-
-// allocate memory with file and line number information
-void *malloc_file_line(size_t size, const char *file, int line);
-
-// free memory with file and line number information
-void free_file_line(void *memory, const char *file, int line);
-
-// called from the exit path of any code that wants to check for unfreed memory
-void dump_unfreed_mem();
-
-
-
-//**************************************************************************
-// INLINE FUNCTIONS
-//**************************************************************************
-
-// standard new/delete operators (try to avoid using)
-ATTR_FORCE_INLINE inline void *operator new(std::size_t size) throw (std::bad_alloc)
-{
- void *result = malloc_file_line(size, NULL, 0);
- if (result == NULL)
- throw std::bad_alloc();
- return result;
-}
-
-ATTR_FORCE_INLINE inline void *operator new[](std::size_t size) throw (std::bad_alloc)
-{
- void *result = malloc_file_line(size, NULL, 0);
- if (result == NULL)
- throw std::bad_alloc();
- return result;
-}
-
-ATTR_FORCE_INLINE inline void operator delete(void *ptr) throw()
-{
- if (ptr != NULL)
- free_file_line(ptr, NULL, 0);
-}
-
-ATTR_FORCE_INLINE inline void operator delete[](void *ptr) throw()
-{
- if (ptr != NULL)
- free_file_line(ptr, NULL, 0);
-}
-
-
-// file/line new/delete operators
-ATTR_FORCE_INLINE inline void *operator new(std::size_t size, const char *file, int line) throw (std::bad_alloc)
-{
- void *result = malloc_file_line(size, file, line);
- if (result == NULL)
- throw std::bad_alloc();
- return result;
-}
-
-ATTR_FORCE_INLINE inline void *operator new[](std::size_t size, const char *file, int line) throw (std::bad_alloc)
-{
- void *result = malloc_file_line(size, file, line);
- if (result == NULL)
- throw std::bad_alloc();
- return result;
-}
-
-ATTR_FORCE_INLINE inline void operator delete(void *ptr, const char *file, int line)
-{
- if (ptr != NULL)
- free_file_line(ptr, file, line);
-}
-
-ATTR_FORCE_INLINE inline void operator delete[](void *ptr, const char *file, int line)
-{
- if (ptr != NULL)
- free_file_line(ptr, file, line);
-}
-
-
-// file/line new/delete operators with zeroing
-ATTR_FORCE_INLINE inline void *operator new(std::size_t size, const char *file, int line, const zeromem_t &) throw (std::bad_alloc)
-{
- void *result = malloc_file_line(size, file, line);
- if (result == NULL)
- throw std::bad_alloc();
- memset(result, 0, size);
- return result;
-}
-
-ATTR_FORCE_INLINE inline void *operator new[](std::size_t size, const char *file, int line, const zeromem_t &) throw (std::bad_alloc)
-{
- void *result = malloc_file_line(size, file, line);
- if (result == NULL)
- throw std::bad_alloc();
- memset(result, 0, size);
- return result;
-}
-
-ATTR_FORCE_INLINE inline void operator delete(void *ptr, const char *file, int line, const zeromem_t &)
-{
- if (ptr != NULL)
- free_file_line(ptr, file, line);
-}
-
-ATTR_FORCE_INLINE inline void operator delete[](void *ptr, const char *file, int line, const zeromem_t &)
-{
- if (ptr != NULL)
- free_file_line(ptr, file, line);
-}
-
-
-
-//**************************************************************************
// ADDDITIONAL MACROS
//**************************************************************************