From cfa887f3de933df22134893751072819c7aa1e02 Mon Sep 17 00:00:00 2001 From: Aaron Giles Date: Thu, 25 Feb 2010 06:28:03 +0000 Subject: Changed all driver_data structs into classes with a simple constructor and a static allocation function. Changed MDRV_DRIVER_DATA to reference driver_data::alloc instead of just providing a size. This function is called to allocate the driver data. This allows objects to be embedded in the state data and be properly initialized. Ideally, new driver_data constructors should perform initialization actions in the constructor, but for now most just use auto_alloc_clear() to blast everything to zero. Moved driver data allocation after device list construction so that devices can be found when the driver data is constructed. --- src/emu/mame.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/emu/mame.c') diff --git a/src/emu/mame.c b/src/emu/mame.c index 9915dc9dcb0..d6c27f46a12 100644 --- a/src/emu/mame.c +++ b/src/emu/mame.c @@ -1303,13 +1303,13 @@ running_machine::running_machine(const game_driver *driver) basename = mame_strdup(driver->name); config = machine_config_alloc(driver->machine_config); - /* allocate the driver data */ - if (config->driver_data_size != 0) - driver_data = auto_alloc_array_clear(this, UINT8, config->driver_data_size); - /* attach this machine to all the devices in the configuration */ devicelist.import_config_list(config->devicelist, *this); + /* allocate the driver data (after devices) */ + if (config->driver_data_alloc != NULL) + driver_data = (*config->driver_data_alloc)(*this); + /* find devices */ firstcpu = cpu_first(this); primary_screen = video_screen_first(this); -- cgit v1.2.3-70-g09d2