mirror of
https://github.com/holub/mame
synced 2025-04-23 00:39:36 +03:00
replaced some malloc/free usage with global_alloc_array/global_free_array (nw)
This commit is contained in:
parent
826c2fea22
commit
513738066d
@ -111,7 +111,7 @@ bool rom_image_device::call_load()
|
||||
device_image_interface* image = this;
|
||||
UINT64 size = image->length();
|
||||
|
||||
m_base = (UINT8*)malloc(16384);
|
||||
m_base = global_alloc_array(UINT8, 16384);
|
||||
if(size <= 16384)
|
||||
{
|
||||
image->fread(m_base,size);
|
||||
@ -131,6 +131,6 @@ bool rom_image_device::call_load()
|
||||
-------------------------------------------------*/
|
||||
void rom_image_device::call_unload()
|
||||
{
|
||||
free(m_base);
|
||||
global_free_array(m_base);
|
||||
m_base = NULL;
|
||||
}
|
||||
|
@ -308,7 +308,7 @@ WRITE8_MEMBER(snug_enhanced_video_device::cruwrite)
|
||||
void snug_enhanced_video_device::device_start()
|
||||
{
|
||||
m_dsrrom = memregion(DSRROM)->base();
|
||||
m_novram = (UINT8*)malloc(NOVRAM_SIZE);
|
||||
m_novram = global_alloc_array(UINT8, NOVRAM_SIZE);
|
||||
}
|
||||
|
||||
void snug_enhanced_video_device::device_reset()
|
||||
@ -323,7 +323,7 @@ void snug_enhanced_video_device::device_reset()
|
||||
|
||||
void snug_enhanced_video_device::device_stop()
|
||||
{
|
||||
free(m_novram);
|
||||
global_free_array(m_novram);
|
||||
}
|
||||
|
||||
ROM_START( ti99_evpc )
|
||||
|
@ -577,8 +577,8 @@ void snug_high_speed_gpl_device::grom_write(address_space& space, offs_t offset,
|
||||
|
||||
void snug_high_speed_gpl_device::device_start()
|
||||
{
|
||||
m_ram6_memory = (UINT8*)malloc(RAMSIZE);
|
||||
m_gram_memory = (UINT8*)malloc(GRAMSIZE);
|
||||
m_ram6_memory = global_alloc_array(UINT8, RAMSIZE);
|
||||
m_gram_memory = global_alloc_array(UINT8, GRAMSIZE);
|
||||
}
|
||||
|
||||
void snug_high_speed_gpl_device::device_reset()
|
||||
@ -614,8 +614,8 @@ void snug_high_speed_gpl_device::device_config_complete(void)
|
||||
|
||||
void snug_high_speed_gpl_device::device_stop()
|
||||
{
|
||||
free(m_ram6_memory);
|
||||
free(m_gram_memory);
|
||||
global_free_array(m_ram6_memory);
|
||||
global_free_array(m_gram_memory);
|
||||
}
|
||||
|
||||
// Flash setting is used to flash an empty HSGPL DSR ROM
|
||||
|
@ -1039,14 +1039,14 @@ void ti_rs232_pio_device::device_start()
|
||||
m_serdev[1] = subdevice<ti_rs232_attached_device>("serdev1");
|
||||
m_piodev = subdevice<ti_pio_attached_device>("piodev");
|
||||
// Prepare the receive buffers
|
||||
m_recvbuf[0] = (UINT8*)malloc(512);
|
||||
m_recvbuf[1] = (UINT8*)malloc(512);
|
||||
m_recvbuf[0] = global_alloc_array(UINT8, 512);
|
||||
m_recvbuf[1] = global_alloc_array(UINT8, 512);
|
||||
}
|
||||
|
||||
void ti_rs232_pio_device::device_stop()
|
||||
{
|
||||
if (m_recvbuf[0] != NULL) free(m_recvbuf[0]);
|
||||
if (m_recvbuf[1] != NULL) free(m_recvbuf[1]);
|
||||
if (m_recvbuf[0] != NULL) global_free_array(m_recvbuf[0]);
|
||||
if (m_recvbuf[1] != NULL) global_free_array(m_recvbuf[1]);
|
||||
}
|
||||
|
||||
void ti_rs232_pio_device::device_reset()
|
||||
|
@ -430,7 +430,7 @@ void device_image_interface::run_hash(void (*partialhash)(hash_collection &, con
|
||||
hashes.reset();
|
||||
size = (UINT32) length();
|
||||
|
||||
buf = (UINT8*)malloc(size);
|
||||
buf = global_alloc_array(UINT8, size);
|
||||
memset(buf,0,size);
|
||||
|
||||
/* read the file */
|
||||
@ -443,7 +443,7 @@ void device_image_interface::run_hash(void (*partialhash)(hash_collection &, con
|
||||
hashes.compute(buf, size, types);
|
||||
|
||||
/* cleanup */
|
||||
free(buf);
|
||||
global_free_array(buf);
|
||||
fseek(0, SEEK_SET);
|
||||
}
|
||||
|
||||
|
@ -403,16 +403,16 @@ WRITE8_MEMBER( at29040a_device::write )
|
||||
|
||||
void at29040a_device::device_start(void)
|
||||
{
|
||||
m_programming_buffer = (UINT8*)malloc(SECTOR_SIZE);
|
||||
m_programming_buffer = global_alloc_array(UINT8, SECTOR_SIZE);
|
||||
m_programming_timer = timer_alloc(PRG_TIMER);
|
||||
|
||||
m_eememory = (UINT8*)malloc(FEEPROM_SIZE+2);
|
||||
m_eememory = global_alloc_array(UINT8, FEEPROM_SIZE+2);
|
||||
}
|
||||
|
||||
void at29040a_device::device_stop(void)
|
||||
{
|
||||
free(m_programming_buffer);
|
||||
free(m_eememory);
|
||||
global_free_array(m_programming_buffer);
|
||||
global_free_array(m_eememory);
|
||||
}
|
||||
|
||||
void at29040a_device::device_reset(void)
|
||||
|
@ -776,7 +776,7 @@ void smc92x4_device::data_transfer_read(chrn_id_hd id, int transfer_enable)
|
||||
|
||||
sector_len = 1 << (id.N+7);
|
||||
sector_data_id = id.data_id;
|
||||
buf = (UINT8 *)malloc(sector_len);
|
||||
buf = global_alloc_array(UINT8, sector_len);
|
||||
|
||||
if (m_selected_drive_type & TYPE_FLOPPY)
|
||||
{
|
||||
@ -802,7 +802,7 @@ void smc92x4_device::data_transfer_read(chrn_id_hd id, int transfer_enable)
|
||||
}
|
||||
m_out_dip(CLEAR_LINE);
|
||||
}
|
||||
free(buf);
|
||||
global_free_array(buf);
|
||||
|
||||
/* Check CRC. We assume everything is OK, no retry required. */
|
||||
m_register_r[CHIP_STATUS] &= ~CS_RETREQ;
|
||||
@ -857,7 +857,7 @@ void smc92x4_device::data_transfer_write(chrn_id_hd id, int deldata, int redcur,
|
||||
sector_len = 1 << (id.N+7);
|
||||
sector_data_id = id.data_id;
|
||||
|
||||
buf = (UINT8 *)malloc(sector_len);
|
||||
buf = global_alloc_array(UINT8, sector_len);
|
||||
|
||||
/* Copy via DMA from controller RAM. */
|
||||
set_dma_address(DMA23_16, DMA15_8, DMA7_0);
|
||||
@ -884,7 +884,7 @@ void smc92x4_device::data_transfer_write(chrn_id_hd id, int deldata, int redcur,
|
||||
harddisk = static_cast<mfm_harddisk_device *>(m_drive);
|
||||
harddisk->write_sector(id.C, id.H, id.R, buf);
|
||||
}
|
||||
free(buf);
|
||||
global_free_array(buf);
|
||||
sync_status_in();
|
||||
|
||||
m_register_r[CHIP_STATUS] &= ~CS_RETREQ;
|
||||
@ -1360,7 +1360,7 @@ void smc92x4_device::format_floppy_track(int flags)
|
||||
}
|
||||
|
||||
/* Build buffer */
|
||||
buffer = (UINT8*)malloc(data_count);
|
||||
buffer = global_alloc_array(UINT8, data_count);
|
||||
|
||||
fm = in_single_density_mode();
|
||||
|
||||
@ -1489,7 +1489,7 @@ void smc92x4_device::format_floppy_track(int flags)
|
||||
index += gap4;
|
||||
|
||||
floppy_drive_write_track_data_info_buffer(m_drive, m_register_w[DESIRED_HEAD]&0x0f, (char *)buffer, &data_count);
|
||||
free(buffer);
|
||||
global_free_array(buffer);
|
||||
sync_status_in();
|
||||
}
|
||||
|
||||
@ -1528,7 +1528,7 @@ void smc92x4_device::format_harddisk_track(int flags)
|
||||
|
||||
data_count = gap1 + count*(sync+12+gap2+sync+size*128+gap3)+gap4;
|
||||
|
||||
buffer = (UINT8*)malloc(data_count);
|
||||
buffer = global_alloc_array(UINT8, data_count);
|
||||
|
||||
index = 0;
|
||||
gap_byte = 0x4e;
|
||||
@ -1590,7 +1590,7 @@ void smc92x4_device::format_harddisk_track(int flags)
|
||||
// Now write the whole track
|
||||
harddisk->write_track(m_register_w[DESIRED_HEAD]&0x0f, buffer, data_count);
|
||||
|
||||
free(buffer);
|
||||
global_free_array(buffer);
|
||||
sync_status_in();
|
||||
}
|
||||
|
||||
@ -1636,7 +1636,7 @@ void smc92x4_device::read_floppy_track(bool transfer_only_ids)
|
||||
data_count = TRKSIZE_DD;
|
||||
}
|
||||
|
||||
buffer = (UINT8*)malloc(data_count);
|
||||
buffer = global_alloc_array(UINT8, data_count);
|
||||
|
||||
floppy_drive_read_track_data_info_buffer(m_drive, m_register_w[DESIRED_HEAD]&0x0f, (char *)buffer, &data_count);
|
||||
sync_status_in();
|
||||
@ -1657,7 +1657,7 @@ void smc92x4_device::read_floppy_track(bool transfer_only_ids)
|
||||
}
|
||||
m_out_dip(CLEAR_LINE);
|
||||
|
||||
free(buffer);
|
||||
global_free_array(buffer);
|
||||
}
|
||||
|
||||
void smc92x4_device::read_harddisk_track(bool transfer_only_ids)
|
||||
@ -1671,7 +1671,7 @@ void smc92x4_device::read_harddisk_track(bool transfer_only_ids)
|
||||
sync_latches_out();
|
||||
|
||||
data_count = harddisk->get_track_length();
|
||||
buffer = (UINT8*)malloc(data_count);
|
||||
buffer = global_alloc_array(UINT8, data_count);
|
||||
|
||||
/* buffer and data_count are allocated and set by the function. */
|
||||
harddisk->read_track(m_register_w[DESIRED_HEAD]&0x0f, buffer);
|
||||
@ -1698,7 +1698,7 @@ void smc92x4_device::read_harddisk_track(bool transfer_only_ids)
|
||||
}
|
||||
m_out_dip(CLEAR_LINE);
|
||||
|
||||
free(buffer);
|
||||
global_free_array(buffer);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2140,7 +2140,7 @@ void saturn_state::make_dir_current(UINT32 fad)
|
||||
UINT8 *sect;
|
||||
direntryT *curentry;
|
||||
|
||||
sect = (UINT8 *)malloc(MAX_DIR_SIZE);
|
||||
sect = global_alloc_array(UINT8, MAX_DIR_SIZE);
|
||||
memset(sect, 0, MAX_DIR_SIZE);
|
||||
if(sectlenin != 2048)
|
||||
popmessage("Sector Length %d, contact MAMEdev (1)",sectlenin);
|
||||
@ -2231,7 +2231,7 @@ void saturn_state::make_dir_current(UINT32 fad)
|
||||
}
|
||||
}
|
||||
|
||||
free(sect);
|
||||
global_free_array(sect);
|
||||
}
|
||||
|
||||
void saturn_state::stvcd_exit( void )
|
||||
|
Loading…
Reference in New Issue
Block a user