diff options
author | 2010-01-08 17:18:54 +0000 | |
---|---|---|
committer | 2010-01-08 17:18:54 +0000 | |
commit | a92de5930cef847ffdafd1e6c8e9f2bf03375c39 (patch) | |
tree | e8e5887dfcf861cc77ed1675015267450fc6fc8a /src/emu/config.c | |
parent | a0a40f8815e5c16bd2ab8ee333d19bcfe1e6ee55 (diff) |
Extended the astring class wrapper into something useful, and
useable as a stack object. Also designed the interfaces to allow
for chaining operations. And added a casting operator to const
char * for seamless use in most functions that take plain old C
strings.
Changed all uses of astring to use the object directly on the
stack or embedded in objects instead of explicitly allocating
and deallocating it. Removed a lot of annoying memory management
code as a result.
Changed interfaces that accepted/returned an astring * to
use an astring & instead.
Removed auto_alloc_astring(machine). Use
auto_alloc(machine, astring) instead.
Diffstat (limited to 'src/emu/config.c')
-rw-r--r-- | src/emu/config.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/emu/config.c b/src/emu/config.c index a2290fb1216..72061ce6905 100644 --- a/src/emu/config.c +++ b/src/emu/config.c @@ -118,7 +118,6 @@ int config_load_settings(running_machine *machine) config_type *type; mame_file *file; int loaded = 0; - astring *fname; /* loop over all registrants and call their init function */ for (type = typelist; type; type = type->next) @@ -128,9 +127,8 @@ int config_load_settings(running_machine *machine) if (controller[0] != 0) { /* open the config file */ - fname = astring_assemble_2(astring_alloc(), controller, ".cfg"); - filerr = mame_fopen(SEARCHPATH_CTRLR, astring_c(fname), OPEN_FLAG_READ, &file); - astring_free(fname); + astring fname(controller, ".cfg"); + filerr = mame_fopen(SEARCHPATH_CTRLR, fname, OPEN_FLAG_READ, &file); if (filerr != FILERR_NONE) throw emu_fatalerror("Could not load controller file %s.cfg", controller); @@ -150,9 +148,8 @@ int config_load_settings(running_machine *machine) } /* finally, load the game-specific file */ - fname = astring_assemble_2(astring_alloc(), machine->basename, ".cfg"); - filerr = mame_fopen(SEARCHPATH_CONFIG, astring_c(fname), OPEN_FLAG_READ, &file); - astring_free(fname); + astring fname(machine->basename, ".cfg"); + filerr = mame_fopen(SEARCHPATH_CONFIG, fname, OPEN_FLAG_READ, &file); if (filerr == FILERR_NONE) { @@ -175,7 +172,6 @@ void config_save_settings(running_machine *machine) file_error filerr; config_type *type; mame_file *file; - astring *fname; /* loop over all registrants and call their init function */ for (type = typelist; type; type = type->next) @@ -190,9 +186,8 @@ void config_save_settings(running_machine *machine) } /* finally, save the game-specific file */ - fname = astring_assemble_2(astring_alloc(), machine->basename, ".cfg"); - filerr = mame_fopen(SEARCHPATH_CONFIG, astring_c(fname), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &file); - astring_free(fname); + astring fname(machine->basename, ".cfg"); + filerr = mame_fopen(SEARCHPATH_CONFIG, fname, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &file); if (filerr == FILERR_NONE) { |