summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2009-12-23 16:44:55 +0000
committer Aaron Giles <aaron@aarongiles.com>2009-12-23 16:44:55 +0000
commit201ea424db59083629046a1876e64a0c708f1c69 (patch)
treeda99756661d6a24c786992d711bde7c52f33d61f
parent680184085a7241c66b1eeb8db989c7f37c661700 (diff)
Get rid of explicit resource tracking for state saving. Now we just use
the auto_ allocators, since registration is restricted to initialization.
-rw-r--r--src/emu/restrack.c1
-rw-r--r--src/emu/restrack.h1
-rw-r--r--src/emu/state.c89
-rw-r--r--src/emu/state.h7
4 files changed, 4 insertions, 94 deletions
diff --git a/src/emu/restrack.c b/src/emu/restrack.c
index c3cc5deae11..843fb814eea 100644
--- a/src/emu/restrack.c
+++ b/src/emu/restrack.c
@@ -144,7 +144,6 @@ void begin_resource_tracking(void)
pool_type_register(new_pool, OBJTYPE_ASTRING, "String", astring_destructor);
pool_type_register(new_pool, OBJTYPE_BITMAP, "Bitmap", bitmap_destructor);
pool_type_register(new_pool, OBJTYPE_TIMER, "Timer", timer_destructor);
- pool_type_register(new_pool, OBJTYPE_STATEREG, "Save State Registration", state_destructor);
/* increment the tag counter */
resource_tracking_tag++;
diff --git a/src/emu/restrack.h b/src/emu/restrack.h
index d62cc0e7a21..570291aa3a7 100644
--- a/src/emu/restrack.h
+++ b/src/emu/restrack.h
@@ -24,7 +24,6 @@
#define OBJTYPE_ASTRING OBJECT_TYPE('a','s','t','r')
#define OBJTYPE_BITMAP OBJECT_TYPE('b','i','t','m')
#define OBJTYPE_TIMER OBJECT_TYPE('t','i','m','r')
-#define OBJTYPE_STATEREG OBJECT_TYPE('s','t','a','t')
diff --git a/src/emu/state.c b/src/emu/state.c
index 09237920cf4..93a8aac8989 100644
--- a/src/emu/state.c
+++ b/src/emu/state.c
@@ -242,7 +242,7 @@ void state_save_register_memory(running_machine *machine, const char *module, co
}
/* create the full name */
- totalname = astring_alloc();
+ totalname = auto_astring_alloc(machine);
if (tag != NULL)
astring_printf(totalname, "%s/%s/%X/%s", module, tag, index, name);
else
@@ -263,7 +263,7 @@ void state_save_register_memory(running_machine *machine, const char *module, co
/* didn't find one; allocate a new one */
next = *entryptr;
- *entryptr = alloc_clear_or_die(state_entry);
+ *entryptr = auto_alloc_clear(machine, state_entry);
/* fill in the rest */
(*entryptr)->next = next;
@@ -272,7 +272,6 @@ void state_save_register_memory(running_machine *machine, const char *module, co
(*entryptr)->name = totalname;
(*entryptr)->typesize = valsize;
(*entryptr)->typecount = valcount;
- restrack_register_object(OBJTYPE_STATEREG, *entryptr, 0, file, line);
}
@@ -312,14 +311,13 @@ void state_save_register_presave(running_machine *machine, state_presave_func fu
fatalerror("Duplicate save state function (%p, %p)", param, func);
/* allocate a new entry */
- *cbptr = alloc_or_die(state_callback);
+ *cbptr = auto_alloc(machine, state_callback);
/* fill it in */
(*cbptr)->next = NULL;
(*cbptr)->machine = machine;
(*cbptr)->func.presave = func;
(*cbptr)->param = param;
- restrack_register_object(OBJTYPE_STATEREG, *cbptr, 1, __FILE__, __LINE__);
}
@@ -343,92 +341,13 @@ void state_save_register_postload(running_machine *machine, state_postload_func
fatalerror("Duplicate save state function (%p, %p)", param, func);
/* allocate a new entry */
- *cbptr = alloc_or_die(state_callback);
+ *cbptr = auto_alloc(machine, state_callback);
/* fill it in */
(*cbptr)->next = NULL;
(*cbptr)->machine = machine;
(*cbptr)->func.postload = func;
(*cbptr)->param = param;
- restrack_register_object(OBJTYPE_STATEREG, *cbptr, 2, __FILE__, __LINE__);
-}
-
-
-
-/***************************************************************************
- REGISTRATION FREEING
-***************************************************************************/
-
-/*-------------------------------------------------
- func_free - free registered functions attached
- to the current resource tag
--------------------------------------------------*/
-
-static void func_free(state_callback **rootptr, void *ptr)
-{
- state_callback **cbptr;
-
- /* iterate over the function list */
- for (cbptr = rootptr; *cbptr != NULL; cbptr = &(*cbptr)->next)
- if (*cbptr == ptr)
- {
- state_callback *cb = *cbptr;
-
- /* de-link us from the list and free our memory */
- *cbptr = (*cbptr)->next;
- free(cb);
- break;
- }
-}
-
-
-/*-------------------------------------------------
- state_save_free - free all registrations that
- have been tagged with the current resource
- tag
--------------------------------------------------*/
-
-void state_destructor(void *ptr, size_t size)
-{
- state_private *global = NULL;
-
- /* size of 0 means an entry */
- if (size == 0)
- {
- state_entry **entryptr;
-
- /* iterate over entries */
- global = ((state_entry *)ptr)->machine->state_data;
- for (entryptr = &global->entrylist; *entryptr != NULL; entryptr = &(*entryptr)->next)
- if (*entryptr == ptr)
- {
- state_entry *entry = *entryptr;
-
- /* de-link us from the list and free our memory */
- *entryptr = (*entryptr)->next;
- astring_free(entry->name);
- free(entry);
- break;
- }
- }
-
- /* size of 1 means a pre function */
- else if (size == 1)
- {
- global = ((state_callback *)ptr)->machine->state_data;
- func_free(&global->prefunclist, ptr);
- }
-
- /* size of 2 means a post function */
- else if (size == 2)
- {
- global = ((state_callback *)ptr)->machine->state_data;
- func_free(&global->postfunclist, ptr);
- }
-
- /* if we're clear of all registrations, reset the invalid counter */
- if (global != NULL && global->entrylist == NULL && global->prefunclist == NULL && global->postfunclist == NULL)
- global->illegal_regs = 0;
}
diff --git a/src/emu/state.h b/src/emu/state.h
index 06a846a2a9d..afe628dcb35 100644
--- a/src/emu/state.h
+++ b/src/emu/state.h
@@ -166,13 +166,6 @@ void state_save_register_postload(running_machine *machine, state_postload_func
-/* ----- registration freeing ----- */
-
-/* free all registrations that have been tagged with the current resource tag */
-void state_destructor(void *ptr, size_t size);
-
-
-
/* ----- save state file processing ----- */
/* check if a file is a valid save state */