diff options
author | 2014-03-28 15:32:15 +0000 | |
---|---|---|
committer | 2014-03-28 15:32:15 +0000 | |
commit | f963d0bcd73fba69112e529071ef7507d29c7584 (patch) | |
tree | 9cfb517f49d7e7bef2299e3003b9d1e85794b914 /src/mess/machine | |
parent | 513738066d94b89185222f997fd0c715acc72d5f (diff) |
replaced some more malloc/free usage with global_alloc_array/global_free_array (nw)
Diffstat (limited to 'src/mess/machine')
-rw-r--r-- | src/mess/machine/amstrad.c | 6 | ||||
-rw-r--r-- | src/mess/machine/atarifdc.h | 2 | ||||
-rw-r--r-- | src/mess/machine/cbm_snqk.c | 6 | ||||
-rw-r--r-- | src/mess/machine/hp48.c | 4 | ||||
-rw-r--r-- | src/mess/machine/lviv.c | 6 | ||||
-rw-r--r-- | src/mess/machine/microtan.c | 9 | ||||
-rw-r--r-- | src/mess/machine/nc.c | 6 | ||||
-rw-r--r-- | src/mess/machine/primo.c | 14 | ||||
-rw-r--r-- | src/mess/machine/spec_snqk.c | 12 | ||||
-rw-r--r-- | src/mess/machine/ti85.c | 4 | ||||
-rw-r--r-- | src/mess/machine/ti99/datamux.c | 4 | ||||
-rw-r--r-- | src/mess/machine/ti99/gromport.c | 6 | ||||
-rw-r--r-- | src/mess/machine/x68k_hdc.c | 4 |
13 files changed, 42 insertions, 41 deletions
diff --git a/src/mess/machine/amstrad.c b/src/mess/machine/amstrad.c index 48afac95ae1..030866d689e 100644 --- a/src/mess/machine/amstrad.c +++ b/src/mess/machine/amstrad.c @@ -3155,7 +3155,7 @@ SNAPSHOT_LOAD_MEMBER( amstrad_state,amstrad) if (snapshot_size < 8) return IMAGE_INIT_FAIL; - snapshot = (UINT8 *)malloc(snapshot_size); + snapshot = global_alloc_array(UINT8, snapshot_size); if (!snapshot) return IMAGE_INIT_FAIL; @@ -3164,12 +3164,12 @@ SNAPSHOT_LOAD_MEMBER( amstrad_state,amstrad) if (memcmp(snapshot, "MV - SNA", 8)) { - free(snapshot); + global_free_array(snapshot); return IMAGE_INIT_FAIL; } amstrad_handle_snapshot(snapshot); - free(snapshot); + global_free_array(snapshot); return IMAGE_INIT_PASS; } diff --git a/src/mess/machine/atarifdc.h b/src/mess/machine/atarifdc.h index 334c4bd8dbc..6eb132dabbc 100644 --- a/src/mess/machine/atarifdc.h +++ b/src/mess/machine/atarifdc.h @@ -32,7 +32,7 @@ private: struct atari_drive { - UINT8 *image; /* malloc'd image */ + UINT8 *image; /* alloc'd image */ int type; /* type of image (XFD, ATR, DSK) */ int mode; /* 0 read only, != 0 read/write */ int density; /* 0 SD, 1 MD, 2 DD */ diff --git a/src/mess/machine/cbm_snqk.c b/src/mess/machine/cbm_snqk.c index 116d5b2f3d0..816911110cd 100644 --- a/src/mess/machine/cbm_snqk.c +++ b/src/mess/machine/cbm_snqk.c @@ -69,7 +69,7 @@ int general_cbm_loadsnap( device_image_interface &image, const char *file_type, address = 2049; snapshot_size -= 2; - data = (UINT8*)malloc(snapshot_size); + data = global_alloc_array(UINT8, snapshot_size); if (!data) goto error; @@ -81,12 +81,12 @@ int general_cbm_loadsnap( device_image_interface &image, const char *file_type, space.write_byte(address + i + offset, data[i]); cbm_sethiaddress(space, address + snapshot_size); - free(data); + global_free_array(data); return IMAGE_INIT_PASS; error: if (data) - free(data); + global_free_array(data); return IMAGE_INIT_FAIL; } diff --git a/src/mess/machine/hp48.c b/src/mess/machine/hp48.c index e94bffe09a8..9c3c4774ec5 100644 --- a/src/mess/machine/hp48.c +++ b/src/mess/machine/hp48.c @@ -992,7 +992,7 @@ void hp48_port_image_device::hp48_fill_port() struct hp48_port_interface* conf = (struct hp48_port_interface*) static_config(); int size = state->m_port_size[conf->port]; LOG(( "hp48_fill_port: %s module=%i size=%i rw=%i\n", tag(), conf->module, size, state->m_port_write[conf->port] )); - state->m_port_data[conf->port] = (UINT8*)malloc( 2 * size ); + state->m_port_data[conf->port] = global_alloc_array(UINT8, 2 * size); memset( state->m_port_data[conf->port], 0, 2 * size ); state->m_modules[conf->module].off_mask = 2 * (( size > 128 * 1024 ) ? 128 * 1024 : size) - 1; state->m_modules[conf->module].read = read8_delegate(); @@ -1072,7 +1072,7 @@ void hp48_port_image_device::call_unload() fseek( 0, SEEK_SET ); fwrite( state->m_port_data[conf->port], state->m_port_size[conf->port] ); } - free( state->m_port_data[conf->port] ); + global_free_array( state->m_port_data[conf->port] ); hp48_unfill_port(); state->hp48_apply_modules(); } diff --git a/src/mess/machine/lviv.c b/src/mess/machine/lviv.c index 2e871a5c16b..2088f3f02cd 100644 --- a/src/mess/machine/lviv.c +++ b/src/mess/machine/lviv.c @@ -323,7 +323,7 @@ SNAPSHOT_LOAD_MEMBER( lviv_state, lviv ) { UINT8 *lviv_snapshot_data; - lviv_snapshot_data = (UINT8*)malloc(LVIV_SNAPSHOT_SIZE); + lviv_snapshot_data = global_alloc_array(UINT8, LVIV_SNAPSHOT_SIZE); if (!lviv_snapshot_data) { logerror ("Unable to load snapshot file\n"); @@ -334,7 +334,7 @@ SNAPSHOT_LOAD_MEMBER( lviv_state, lviv ) if(lviv_verify_snapshot(lviv_snapshot_data, snapshot_size) == IMAGE_VERIFY_FAIL) { - free(lviv_snapshot_data); + global_free_array(lviv_snapshot_data); return IMAGE_INIT_FAIL; } @@ -342,7 +342,7 @@ SNAPSHOT_LOAD_MEMBER( lviv_state, lviv ) dump_registers(); - free(lviv_snapshot_data); + global_free_array(lviv_snapshot_data); logerror("Snapshot file loaded\n"); return IMAGE_INIT_PASS; diff --git a/src/mess/machine/microtan.c b/src/mess/machine/microtan.c index c4250f5b13b..f7da67aa36b 100644 --- a/src/mess/machine/microtan.c +++ b/src/mess/machine/microtan.c @@ -840,7 +840,7 @@ QUICKLOAD_LOAD_MEMBER( microtan_state, microtan ) int rc; snapshot_size = 8263; /* magic size */ - snapshot_buff = (UINT8*)malloc(snapshot_size); + snapshot_buff = global_alloc_array(UINT8, snapshot_size); if (!snapshot_buff) { logerror("microtan_hexfile_load: could not allocate %d bytes of buffer\n", snapshot_size); @@ -848,10 +848,10 @@ QUICKLOAD_LOAD_MEMBER( microtan_state, microtan ) } memset(snapshot_buff, 0, snapshot_size); - buff = (char*)malloc(quickload_size + 1); + buff = global_alloc_array(char, quickload_size + 1); if (!buff) { - free(snapshot_buff); + global_free_array(snapshot_buff); logerror("microtan_hexfile_load: could not allocate %d bytes of buffer\n", quickload_size); return IMAGE_INIT_FAIL; } @@ -865,6 +865,7 @@ QUICKLOAD_LOAD_MEMBER( microtan_state, microtan ) rc = parse_zillion_hex(snapshot_buff, buff); if (rc == IMAGE_INIT_PASS) microtan_snapshot_copy(snapshot_buff, snapshot_size); - free(snapshot_buff); + global_free_array(buff); + global_free_array(snapshot_buff); return rc; } diff --git a/src/mess/machine/nc.c b/src/mess/machine/nc.c index 7933259b453..7bc56cab3af 100644 --- a/src/mess/machine/nc.c +++ b/src/mess/machine/nc.c @@ -61,8 +61,8 @@ int nc_state::nc_card_load(device_image_interface &image, unsigned char **ptr) if (datasize!=0) { - /* malloc memory for this data */ - data = (unsigned char *)malloc(datasize); + /* alloc memory for this data */ + data = global_alloc_array(unsigned char, datasize); if (data!=NULL) { @@ -130,7 +130,7 @@ DEVICE_IMAGE_UNLOAD_MEMBER( nc_state, nc_pcmcia_card ) /* free ram allocated to card */ if (m_card_ram!=NULL) { - free(m_card_ram); + global_free_array(m_card_ram); m_card_ram = NULL; } m_card_size = 0; diff --git a/src/mess/machine/primo.c b/src/mess/machine/primo.c index 759ad9192c3..2555ec25cfe 100644 --- a/src/mess/machine/primo.c +++ b/src/mess/machine/primo.c @@ -301,24 +301,24 @@ SNAPSHOT_LOAD_MEMBER( primo_state, primo ) { UINT8 *snapshot_data; - if (!(snapshot_data = (UINT8*) malloc(snapshot_size))) + if (!(snapshot_data = global_alloc_array(UINT8, snapshot_size))) return IMAGE_INIT_FAIL; if (image.fread( snapshot_data, snapshot_size) != snapshot_size) { - free(snapshot_data); + global_free_array(snapshot_data); return IMAGE_INIT_FAIL; } if (strncmp((char *)snapshot_data, "PS01", 4)) { - free(snapshot_data); + global_free_array(snapshot_data); return IMAGE_INIT_FAIL; } primo_setup_pss(snapshot_data, snapshot_size); - free(snapshot_data); + global_free_array(snapshot_data); return IMAGE_INIT_PASS; } @@ -352,17 +352,17 @@ QUICKLOAD_LOAD_MEMBER( primo_state, primo ) { UINT8 *quickload_data; - if (!(quickload_data = (UINT8*) malloc(quickload_size))) + if (!(quickload_data = global_alloc_array(UINT8, quickload_size))) return IMAGE_INIT_FAIL; if (image.fread( quickload_data, quickload_size) != quickload_size) { - free(quickload_data); + global_free_array(quickload_data); return IMAGE_INIT_FAIL; } primo_setup_pp(quickload_data, quickload_size); - free(quickload_data); + global_free_array(quickload_data); return IMAGE_INIT_PASS; } diff --git a/src/mess/machine/spec_snqk.c b/src/mess/machine/spec_snqk.c index bb7417155dc..c076197e0d2 100644 --- a/src/mess/machine/spec_snqk.c +++ b/src/mess/machine/spec_snqk.c @@ -114,7 +114,7 @@ SNAPSHOT_LOAD_MEMBER( spectrum_state,spectrum) { UINT8 *snapshot_data = NULL; - snapshot_data = (UINT8*)malloc(snapshot_size); + snapshot_data = global_alloc_array(UINT8, snapshot_size); if (!snapshot_data) goto error; @@ -233,13 +233,13 @@ SNAPSHOT_LOAD_MEMBER( spectrum_state,spectrum) spectrum_setup_z80(machine(), snapshot_data, snapshot_size); } - free(snapshot_data); + global_free_array(snapshot_data); return IMAGE_INIT_PASS; error: if (snapshot_data) - free(snapshot_data); + global_free_array(snapshot_data); return IMAGE_INIT_FAIL; } @@ -2455,7 +2455,7 @@ QUICKLOAD_LOAD_MEMBER( spectrum_state,spectrum) { UINT8 *quickload_data = NULL; - quickload_data = (UINT8*)malloc(quickload_size); + quickload_data = global_alloc_array(UINT8, quickload_size); if (!quickload_data) goto error; @@ -2480,13 +2480,13 @@ QUICKLOAD_LOAD_MEMBER( spectrum_state,spectrum) spectrum_setup_raw(machine(), quickload_data, quickload_size); } - free(quickload_data); + global_free_array(quickload_data); return IMAGE_INIT_PASS; error: if (quickload_data) - free(quickload_data); + global_free_array(quickload_data); return IMAGE_INIT_FAIL; } diff --git a/src/mess/machine/ti85.c b/src/mess/machine/ti85.c index a9ad0d8f598..e384863169c 100644 --- a/src/mess/machine/ti85.c +++ b/src/mess/machine/ti85.c @@ -694,7 +694,7 @@ SNAPSHOT_LOAD_MEMBER( ti85_state, ti8x ) return IMAGE_INIT_FAIL; } - if (!(ti8x_snapshot_data = (UINT8*)malloc(snapshot_size))) + if (!(ti8x_snapshot_data = global_alloc_array(UINT8, snapshot_size))) return IMAGE_INIT_FAIL; image.fread( ti8x_snapshot_data, snapshot_size); @@ -704,6 +704,6 @@ SNAPSHOT_LOAD_MEMBER( ti85_state, ti8x ) else if (!strncmp(machine().system().name, "ti86", 4)) ti86_setup_snapshot(ti8x_snapshot_data); - free(ti8x_snapshot_data); + global_free_array(ti8x_snapshot_data); return IMAGE_INIT_PASS; } diff --git a/src/mess/machine/ti99/datamux.c b/src/mess/machine/ti99/datamux.c index 77ff2412312..5985a537156 100644 --- a/src/mess/machine/ti99/datamux.c +++ b/src/mess/machine/ti99/datamux.c @@ -392,7 +392,7 @@ void ti99_datamux_device::device_start(void) void ti99_datamux_device::device_stop(void) { - if (m_ram16b) free(m_ram16b); + if (m_ram16b) global_free_array(m_ram16b); } void ti99_datamux_device::device_reset(void) @@ -410,7 +410,7 @@ void ti99_datamux_device::device_reset(void) // better use a region? if (m_ram16b==NULL) { - m_ram16b = (UINT16*)malloc(32768); + m_ram16b = global_alloc_array(UINT16, 32768/2); memset(m_ram16b, 0, 32768); } diff --git a/src/mess/machine/ti99/gromport.c b/src/mess/machine/ti99/gromport.c index 6ea40667601..083e379f3ef 100644 --- a/src/mess/machine/ti99/gromport.c +++ b/src/mess/machine/ti99/gromport.c @@ -2337,7 +2337,7 @@ rpk* rpk_reader::open(emu_options &options, const char *filename, const char *sy if (header == NULL) throw rpk_exception(RPK_MISSING_LAYOUT); /* reserve space for the layout file contents (+1 for the termination) */ - layout_text = (char*)malloc(header->uncompressed_length + 1); + layout_text = global_alloc_array(char, header->uncompressed_length + 1); if (layout_text == NULL) throw rpk_exception(RPK_OUT_OF_MEMORY); /* uncompress the layout text */ @@ -2429,14 +2429,14 @@ rpk* rpk_reader::open(emu_options &options, const char *filename, const char *sy { newrpk->close(); if (zipfile != NULL) zip_file_close(zipfile); - if (layout_text != NULL) free(layout_text); + if (layout_text != NULL) global_free_array(layout_text); // rethrow the exception throw exp; } if (zipfile != NULL) zip_file_close(zipfile); - if (layout_text != NULL) free(layout_text); + if (layout_text != NULL) global_free_array(layout_text); return newrpk; } diff --git a/src/mess/machine/x68k_hdc.c b/src/mess/machine/x68k_hdc.c index 65a5bfbdeb2..467ad1045cd 100644 --- a/src/mess/machine/x68k_hdc.c +++ b/src/mess/machine/x68k_hdc.c @@ -265,11 +265,11 @@ WRITE16_MEMBER( x68k_hdc_image_device::hdc_w ) lba |= m_command[2] << 8; lba |= (m_command[1] & 0x1f) << 16; fseek(lba * 256,SEEK_SET); - blk = (char*)malloc(256*33); + blk = global_alloc_array(char, 256*33); memset(blk,0,256*33); // formats 33 256-byte blocks fwrite(blk,256*33); - free(blk); + global_free_array(blk); logerror("SASI: FORMAT UNIT (LBA 0x%06x)\n",lba); break; default: |