mirror of
https://github.com/holub/mame
synced 2025-05-23 14:19:01 +03:00
Wrapped the global_resource_pool into a function in an attempt to
ensure it is initialized before anyone that references it.
This commit is contained in:
parent
bc6f400f27
commit
eb79c00418
@ -112,9 +112,6 @@ private:
|
|||||||
// GLOBALS
|
// GLOBALS
|
||||||
//**************************************************************************
|
//**************************************************************************
|
||||||
|
|
||||||
// global resource pool to handle allocations outside of the emulator context
|
|
||||||
resource_pool global_resource_pool(6151);
|
|
||||||
|
|
||||||
// dummy zeromem object
|
// dummy zeromem object
|
||||||
const zeromem_t zeromem = { };
|
const zeromem_t zeromem = { };
|
||||||
|
|
||||||
@ -126,6 +123,12 @@ bool memory_entry::s_tracking = false;
|
|||||||
memory_entry *memory_entry::s_hash[memory_entry::k_hash_prime] = { NULL };
|
memory_entry *memory_entry::s_hash[memory_entry::k_hash_prime] = { NULL };
|
||||||
memory_entry *memory_entry::s_freehead = NULL;
|
memory_entry *memory_entry::s_freehead = NULL;
|
||||||
|
|
||||||
|
// wrapper for the global resource pool to help ensure construction order
|
||||||
|
resource_pool &global_resource_pool()
|
||||||
|
{
|
||||||
|
static resource_pool s_pool(6151);
|
||||||
|
return s_pool;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
//**************************************************************************
|
//**************************************************************************
|
||||||
|
@ -74,11 +74,11 @@
|
|||||||
#define pool_free(_pool, v) (_pool).remove(v)
|
#define pool_free(_pool, v) (_pool).remove(v)
|
||||||
|
|
||||||
// global allocation helpers
|
// global allocation helpers
|
||||||
#define global_alloc(_type) pool_alloc(global_resource_pool, _type)
|
#define global_alloc(_type) pool_alloc(global_resource_pool(), _type)
|
||||||
#define global_alloc_clear(_type) pool_alloc_clear(global_resource_pool, _type)
|
#define global_alloc_clear(_type) pool_alloc_clear(global_resource_pool(), _type)
|
||||||
#define global_alloc_array(_type, _num) pool_alloc_array(global_resource_pool, _type, _num)
|
#define global_alloc_array(_type, _num) pool_alloc_array(global_resource_pool(), _type, _num)
|
||||||
#define global_alloc_array_clear(_type, _num) pool_alloc_array_clear(global_resource_pool, _type, _num)
|
#define global_alloc_array_clear(_type, _num) pool_alloc_array_clear(global_resource_pool(), _type, _num)
|
||||||
#define global_free(v) pool_free(global_resource_pool, v)
|
#define global_free(v) pool_free(global_resource_pool(), v)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -281,7 +281,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
resource_pool(int hash_size = 193);
|
resource_pool(int hash_size = 193);
|
||||||
~resource_pool();
|
virtual ~resource_pool();
|
||||||
|
|
||||||
void add(resource_pool_item &item);
|
void add(resource_pool_item &item);
|
||||||
void remove(resource_pool_item &item) { remove(item.m_ptr); }
|
void remove(resource_pool_item &item) { remove(item.m_ptr); }
|
||||||
@ -308,13 +308,13 @@ private:
|
|||||||
// GLOBAL VARIABLES
|
// GLOBAL VARIABLES
|
||||||
//**************************************************************************
|
//**************************************************************************
|
||||||
|
|
||||||
// global resource pool
|
|
||||||
extern resource_pool global_resource_pool;
|
|
||||||
|
|
||||||
// dummy objects to pass to the specialized new variants
|
// dummy objects to pass to the specialized new variants
|
||||||
extern const zeromem_t zeromem;
|
extern const zeromem_t zeromem;
|
||||||
|
|
||||||
|
|
||||||
|
resource_pool &global_resource_pool();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//**************************************************************************
|
//**************************************************************************
|
||||||
// ADDDITIONAL MACROS
|
// ADDDITIONAL MACROS
|
||||||
|
@ -59,8 +59,8 @@ class simple_list
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// construction/destruction
|
// construction/destruction
|
||||||
simple_list(resource_pool &pool = global_resource_pool) :
|
simple_list(resource_pool &pool = global_resource_pool())
|
||||||
m_head(NULL),
|
: m_head(NULL),
|
||||||
m_tail(NULL),
|
m_tail(NULL),
|
||||||
m_pool(pool),
|
m_pool(pool),
|
||||||
m_count(0) { }
|
m_count(0) { }
|
||||||
@ -307,7 +307,7 @@ class fixed_allocator
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// construction/destruction
|
// construction/destruction
|
||||||
fixed_allocator(resource_pool &pool = global_resource_pool)
|
fixed_allocator(resource_pool &pool = global_resource_pool())
|
||||||
: m_freelist(pool) { }
|
: m_freelist(pool) { }
|
||||||
|
|
||||||
// allocate a new item, either by recycling an old one, or by allocating a new one
|
// allocate a new item, either by recycling an old one, or by allocating a new one
|
||||||
@ -343,8 +343,8 @@ class tagged_list
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// construction/destruction
|
// construction/destruction
|
||||||
tagged_list(resource_pool &pool = global_resource_pool) :
|
tagged_list(resource_pool &pool = global_resource_pool())
|
||||||
m_list(pool) { }
|
: m_list(pool) { }
|
||||||
|
|
||||||
// simple getters
|
// simple getters
|
||||||
resource_pool &pool() const { return m_list.pool(); }
|
resource_pool &pool() const { return m_list.pool(); }
|
||||||
|
@ -260,7 +260,7 @@ class render_screen_list
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// construction/destruction
|
// construction/destruction
|
||||||
render_screen_list(resource_pool &pool = global_resource_pool)
|
render_screen_list(resource_pool &pool = global_resource_pool())
|
||||||
: m_list(pool) { }
|
: m_list(pool) { }
|
||||||
|
|
||||||
// getters
|
// getters
|
||||||
|
Loading…
Reference in New Issue
Block a user