mirror of
https://github.com/holub/mame
synced 2025-04-21 16:01:56 +03:00
some dynamic_buffer/dynamic_array usage cleanups (nw)
This commit is contained in:
parent
fd006f5049
commit
2d3b6aece1
@ -430,8 +430,7 @@ void device_image_interface::run_hash(void (*partialhash)(hash_collection &, con
|
||||
hashes.reset();
|
||||
size = (UINT32) length();
|
||||
|
||||
buf.resize(size);
|
||||
memset(buf,0,size);
|
||||
buf.resize_and_clear(size);
|
||||
|
||||
/* read the file */
|
||||
fseek(0, SEEK_SET);
|
||||
|
@ -473,8 +473,7 @@ void gfx_element::set_layout(const gfx_layout &gl, const UINT8 *srcdata)
|
||||
}
|
||||
|
||||
// mark everything dirty
|
||||
m_dirty.resize(m_total_elements);
|
||||
memset(m_dirty, 1, m_total_elements);
|
||||
m_dirty.resize_and_clear(m_total_elements, 1);
|
||||
|
||||
// allocate a pen usage array for entries with 32 pens or less
|
||||
if (m_color_depth <= 32)
|
||||
|
@ -747,8 +747,7 @@ static floperr_t coco_dmk_format_track(floppy_image_legacy *floppy, int head, in
|
||||
track_data = (UINT8 *) track_data_v;
|
||||
|
||||
/* set up sector map */
|
||||
sector_map.resize(sectors);
|
||||
sector_map.clear(0xFF);
|
||||
sector_map.resize_and_clear(sectors, 0xFF);
|
||||
|
||||
physical_sector = 0;
|
||||
for (logical_sector = 0; logical_sector < sectors; logical_sector++)
|
||||
|
@ -207,9 +207,8 @@ static floperr_t z80ne_dmk_format_track(floppy_image_legacy *floppy, int head, i
|
||||
track_data = (UINT8 *) track_data_v;
|
||||
|
||||
/* set up sector map */
|
||||
sector_map.resize(sectors);
|
||||
sector_map.clear(0xFF);
|
||||
|
||||
sector_map.resize_and_clear(sectors, 0xFF);
|
||||
|
||||
physical_sector = 0;
|
||||
for (logical_sector = 0; logical_sector < sectors; logical_sector++)
|
||||
{
|
||||
@ -231,8 +230,7 @@ static floperr_t z80ne_dmk_format_track(floppy_image_legacy *floppy, int head, i
|
||||
sector_length +
|
||||
DMK_DATA_CRC_LEN +
|
||||
DMK_DATA_GAP_LEN);
|
||||
local_sector.resize(local_sector_size);
|
||||
local_sector.clear();
|
||||
local_sector.resize_and_clear(local_sector_size);
|
||||
|
||||
/* set up track table of contents */
|
||||
physical_sector = 0;
|
||||
@ -392,8 +390,7 @@ static floperr_t z80ne_dmk_seek_sector_in_track(floppy_image_legacy *floppy, int
|
||||
DMK_ID_GAP_LEN +
|
||||
DMK_DAM_LEN +
|
||||
DMK_DATA_GAP_LEN);
|
||||
local_idam.resize(local_idam_size);
|
||||
local_idam.clear();
|
||||
local_idam.resize_and_clear(local_idam_size);
|
||||
|
||||
/* search for matching IDAM */
|
||||
for (i = 0; i < DMK_TOC_LEN / 2; i++)
|
||||
@ -572,8 +569,7 @@ static floperr_t internal_z80ne_dmk_read_sector(floppy_image_legacy *floppy, int
|
||||
|
||||
/* set up a local physical sector space (DAM + data + crc + GAP) */
|
||||
local_sector_size = (DMK_DAM_LEN + sector_length + DMK_DATA_CRC_LEN + DMK_DATA_GAP_LEN);
|
||||
local_sector.resize(local_sector_size);
|
||||
local_sector.clear();
|
||||
local_sector.resize_and_clear(local_sector_size);
|
||||
|
||||
/* get sector data */
|
||||
/* create a local copy of sector data including DAM (for crc calculation) */
|
||||
@ -618,8 +614,7 @@ static floperr_t internal_z80ne_dmk_write_sector(floppy_image_legacy *floppy, in
|
||||
|
||||
/* set up a local physical sector space */
|
||||
local_sector_size = (DMK_DAM_LEN + sector_length + DMK_DATA_CRC_LEN + DMK_DATA_GAP_LEN);
|
||||
local_sector.resize(local_sector_size);
|
||||
local_sector.clear();
|
||||
local_sector.resize_and_clear(local_sector_size);
|
||||
if(!ddam)
|
||||
local_sector[0] = 0xFB;
|
||||
else
|
||||
|
@ -2362,8 +2362,7 @@ void chd_file_compressor::compress_begin()
|
||||
m_read_error = false;
|
||||
|
||||
// reset work item state
|
||||
m_work_buffer.resize(hunk_bytes() * (WORK_BUFFER_HUNKS + 1));
|
||||
memset(m_work_buffer, 0, m_work_buffer.count());
|
||||
m_work_buffer.resize_and_clear(hunk_bytes() * (WORK_BUFFER_HUNKS + 1));
|
||||
m_compressed_buffer.resize(hunk_bytes() * WORK_BUFFER_HUNKS);
|
||||
for (int itemnum = 0; itemnum < WORK_BUFFER_HUNKS; itemnum++)
|
||||
{
|
||||
|
@ -75,12 +75,11 @@ const UINT32 *palette_client::dirty_state::dirty_list(UINT32 &mindirty, UINT32 &
|
||||
|
||||
void palette_client::dirty_state::resize(UINT32 colors)
|
||||
{
|
||||
// resize to the correct number of dwords
|
||||
// resize to the correct number of dwords and mark all entries dirty
|
||||
UINT32 dirty_dwords = (colors + 31) / 32;
|
||||
m_dirty.resize(dirty_dwords);
|
||||
m_dirty.resize_and_clear(dirty_dwords, 0xff);
|
||||
|
||||
// mark all entries dirty
|
||||
memset(&m_dirty[0], 0xff, dirty_dwords * sizeof(UINT32));
|
||||
m_dirty[dirty_dwords - 1] &= (1 << (colors % 32)) - 1;
|
||||
|
||||
// set min/max
|
||||
|
@ -2149,9 +2149,8 @@ DRIVER_INIT_MEMBER(sigmab98_state,itazuram)
|
||||
m_rombank = 0x0f;
|
||||
|
||||
// RAM banks
|
||||
m_paletteram.resize(0x3000);
|
||||
m_paletteram.resize_and_clear(0x3000);
|
||||
m_palette->basemem().set(m_paletteram, ENDIANNESS_BIG, 2);
|
||||
memset(m_paletteram, 0, 0x3000);
|
||||
membank("palbank")->set_base(m_paletteram);
|
||||
m_rambank = 0x64;
|
||||
|
||||
@ -2262,8 +2261,7 @@ ROM_END
|
||||
DRIVER_INIT_MEMBER(sigmab98_state,haekaka)
|
||||
{
|
||||
// RAM banks
|
||||
m_paletteram.resize(0x200);
|
||||
memset(m_paletteram, 0, 0x200);
|
||||
m_paletteram.resize_and_clear(0x200);
|
||||
m_palette->basemem().set(m_paletteram, ENDIANNESS_BIG, 2);
|
||||
|
||||
m_spriteram.allocate(0x1000);
|
||||
|
@ -265,8 +265,7 @@ 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.resize(256*33);
|
||||
memset(blk,0,256*33);
|
||||
blk.resize_and_clear(256*33);
|
||||
// formats 33 256-byte blocks
|
||||
fwrite(blk,256*33);
|
||||
logerror("SASI: FORMAT UNIT (LBA 0x%06x)\n",lba);
|
||||
|
@ -101,8 +101,7 @@ imgtoolerr_t imghd_create(imgtool_stream *stream, UINT32 hunksize, UINT32 cylind
|
||||
}
|
||||
|
||||
/* alloc and zero buffer */
|
||||
cache.resize(hunksize);
|
||||
cache.clear();
|
||||
cache.resize_and_clear(hunksize);
|
||||
|
||||
/* zero out every hunk */
|
||||
totalhunks = (logicalbytes + hunksize - 1) / hunksize;
|
||||
|
Loading…
Reference in New Issue
Block a user