summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/emu/cpu/drcfe.c2
-rw-r--r--src/emu/debug/debugcmd.c27
-rw-r--r--src/emu/debug/debugcpu.c21
-rw-r--r--src/emu/debug/debugcpu.h3
-rw-r--r--src/emu/debug/debugvw.c14
-rw-r--r--src/emu/debug/debugvw.h3
-rw-r--r--src/emu/debug/dvdisasm.c50
-rw-r--r--src/emu/debug/dvdisasm.h5
-rw-r--r--src/emu/ioport.c2
-rw-r--r--src/emu/machine/7200fifo.c4
-rw-r--r--src/emu/machine/7200fifo.h2
-rw-r--r--src/emu/machine/at28c16.c8
-rw-r--r--src/emu/machine/at45dbxx.c12
-rw-r--r--src/emu/machine/at45dbxx.h6
-rw-r--r--src/emu/machine/atahle.c4
-rw-r--r--src/emu/machine/atahle.h2
-rw-r--r--src/emu/machine/i2cmem.c15
-rw-r--r--src/emu/machine/i2cmem.h2
-rw-r--r--src/emu/machine/k033906.c7
-rw-r--r--src/emu/machine/k033906.h5
-rw-r--r--src/emu/machine/k056230.c4
-rw-r--r--src/emu/machine/k056230.h2
-rw-r--r--src/emu/machine/laserdsc.c4
-rw-r--r--src/emu/machine/laserdsc.h2
-rw-r--r--src/emu/machine/mc146818.c4
-rw-r--r--src/emu/machine/mc146818.h2
-rw-r--r--src/emu/machine/ram.c8
-rw-r--r--src/emu/machine/ram.h4
-rw-r--r--src/emu/machine/s2636.c33
-rw-r--r--src/emu/machine/s2636.h6
-rw-r--r--src/emu/machine/serflash.c3
-rw-r--r--src/emu/machine/serflash.h2
-rw-r--r--src/emu/machine/stvcd.c17
-rw-r--r--src/emu/machine/tc009xlvc.c11
-rw-r--r--src/emu/machine/tc009xlvc.h12
-rw-r--r--src/emu/machine/timekpr.c6
-rw-r--r--src/emu/machine/timekpr.h2
-rw-r--r--src/emu/memory.c55
-rw-r--r--src/emu/memory.h5
-rw-r--r--src/emu/render.c16
-rw-r--r--src/emu/render.h3
-rw-r--r--src/emu/rendfont.c59
-rw-r--r--src/emu/rendfont.h13
-rw-r--r--src/emu/rendlay.c7
-rw-r--r--src/emu/rendlay.h2
-rw-r--r--src/emu/romload.c4
-rw-r--r--src/emu/sound.c14
-rw-r--r--src/lib/util/coretmpl.h53
-rw-r--r--src/mame/includes/stv.h2
49 files changed, 217 insertions, 332 deletions
diff --git a/src/emu/cpu/drcfe.c b/src/emu/cpu/drcfe.c
index 292c8212793..b1f0957005d 100644
--- a/src/emu/cpu/drcfe.c
+++ b/src/emu/cpu/drcfe.c
@@ -57,7 +57,7 @@ drc_frontend::drc_frontend(device_t &cpu, UINT32 window_start, UINT32 window_end
m_pageshift(m_cpudevice.space_config(AS_PROGRAM)->m_page_shift),
m_desc_live_list(cpu.machine().respool()),
m_desc_allocator(cpu.machine().respool()),
- m_desc_array(window_end + window_start + 2, true)
+ m_desc_array(window_end + window_start + 2, 0)
{
}
diff --git a/src/emu/debug/debugcmd.c b/src/emu/debug/debugcmd.c
index 6f5940973ec..1c3969235c0 100644
--- a/src/emu/debug/debugcmd.c
+++ b/src/emu/debug/debugcmd.c
@@ -54,9 +54,8 @@ struct cheat_map
struct cheat_system
{
char cpu;
- UINT64 length;
UINT8 width;
- cheat_map * cheatmap;
+ dynamic_array<cheat_map> cheatmap;
UINT8 undo;
UINT8 signed_cheat;
UINT8 swapped_cheat;
@@ -419,8 +418,6 @@ void debug_command_init(running_machine &machine)
static void debug_command_exit(running_machine &machine)
{
- if (cheat.length)
- auto_free(machine, cheat.cheatmap);
}
@@ -2041,11 +2038,7 @@ static void execute_cheatinit(running_machine &machine, int ref, int params, con
if (ref == 0)
{
/* initialize new cheat system */
- if (cheat.cheatmap != NULL)
- auto_free(machine, cheat.cheatmap);
- cheat.cheatmap = auto_alloc_array(machine, cheat_map, real_length);
-
- cheat.length = real_length;
+ cheat.cheatmap.resize(real_length);
cheat.undo = 0;
cheat.cpu = (params > 3) ? *param[3] : '0';
}
@@ -2061,14 +2054,8 @@ static void execute_cheatinit(running_machine &machine, int ref, int params, con
if (!debug_command_parameter_cpu_space(machine, &cheat.cpu, AS_PROGRAM, space))
return;
- cheat_map *newmap = auto_alloc_array(machine, cheat_map, cheat.length + real_length);
- for (UINT64 item = 0; item < cheat.length; item++)
- newmap[item] = cheat.cheatmap[item];
- auto_free(machine, cheat.cheatmap);
- cheat.cheatmap = newmap;
-
- active_cheat = cheat.length;
- cheat.length += real_length;
+ active_cheat = cheat.cheatmap.count();
+ cheat.cheatmap.resize_keep(cheat.cheatmap.count() + real_length);
}
/* initialize cheatmap in the selected space */
@@ -2162,7 +2149,7 @@ static void execute_cheatnext(running_machine &machine, int ref, int params, con
cheat.undo++;
/* execute the search */
- for (cheatindex = 0; cheatindex < cheat.length; cheatindex += 1)
+ for (cheatindex = 0; cheatindex < cheat.cheatmap.count(); cheatindex += 1)
if (cheat.cheatmap[cheatindex].state == 1)
{
UINT64 cheat_value = cheat_read_extended(&cheat, *space, cheat.cheatmap[cheatindex].offset);
@@ -2307,7 +2294,7 @@ static void execute_cheatlist(running_machine &machine, int ref, int params, con
}
/* write the cheat list */
- for (cheatindex = 0; cheatindex < cheat.length; cheatindex += 1)
+ for (cheatindex = 0; cheatindex < cheat.cheatmap.count(); cheatindex += 1)
{
if (cheat.cheatmap[cheatindex].state == 1)
{
@@ -2343,7 +2330,7 @@ static void execute_cheatundo(running_machine &machine, int ref, int params, con
if (cheat.undo > 0)
{
- for (cheatindex = 0; cheatindex < cheat.length; cheatindex += 1)
+ for (cheatindex = 0; cheatindex < cheat.cheatmap.count(); cheatindex += 1)
{
if (cheat.cheatmap[cheatindex].undo == cheat.undo)
{
diff --git a/src/emu/debug/debugcpu.c b/src/emu/debug/debugcpu.c
index 66fea18836b..a52534fd630 100644
--- a/src/emu/debug/debugcpu.c
+++ b/src/emu/debug/debugcpu.c
@@ -1628,8 +1628,6 @@ device_debug::device_debug(device_t &device)
m_bplist(NULL),
m_rplist(NULL),
m_trace(NULL),
- m_hotspots(NULL),
- m_hotspot_count(0),
m_hotspot_threshhold(0),
m_track_pc_set(),
m_track_pc(false),
@@ -1983,7 +1981,7 @@ void device_debug::memory_read_hook(address_space &space, offs_t address, UINT64
watchpoint_check(space, WATCHPOINT_READ, address, 0, mem_mask);
// check hotspots
- if (m_hotspots != NULL)
+ if (m_hotspots.count() > 0)
hotspot_check(space, address);
}
@@ -2548,18 +2546,15 @@ void device_debug::registerpoint_enable_all(bool enable)
void device_debug::hotspot_track(int numspots, int threshhold)
{
// if we already have tracking enabled, kill it
- auto_free(m_device.machine(), m_hotspots);
- m_hotspots = NULL;
+ m_hotspots.reset();
// only start tracking if we have a non-zero count
if (numspots > 0)
{
// allocate memory for hotspots
- m_hotspots = auto_alloc_array(m_device.machine(), hotspot_entry, numspots);
- memset(m_hotspots, 0xff, sizeof(*m_hotspots) * numspots);
+ m_hotspots.resize_and_clear(numspots, 0xff);
// fill in the info
- m_hotspot_count = numspots;
m_hotspot_threshhold = threshhold;
}
@@ -2960,7 +2955,7 @@ void device_debug::watchpoint_update_flags(address_space &space)
{
// if hotspots are enabled, turn on all reads
bool enableread = false;
- if (m_hotspots != NULL)
+ if (m_hotspots.count() > 0)
enableread = true;
// see if there are any enabled breakpoints
@@ -3077,20 +3072,20 @@ void device_debug::hotspot_check(address_space &space, offs_t address)
// see if we have a match in our list
int hotindex;
- for (hotindex = 0; hotindex < m_hotspot_count; hotindex++)
+ for (hotindex = 0; hotindex < m_hotspots.count(); hotindex++)
if (m_hotspots[hotindex].m_access == address && m_hotspots[hotindex].m_pc == curpc && m_hotspots[hotindex].m_space == &space)
break;
// if we didn't find any, make a new entry
- if (hotindex == m_hotspot_count)
+ if (hotindex == m_hotspots.count())
{
// if the bottom of the list is over the threshhold, print it
- hotspot_entry &spot = m_hotspots[m_hotspot_count - 1];
+ hotspot_entry &spot = m_hotspots[m_hotspots.count() - 1];
if (spot.m_count > m_hotspot_threshhold)
debug_console_printf(space.machine(), "Hotspot @ %s %08X (PC=%08X) hit %d times (fell off bottom)\n", space.name(), spot.m_access, spot.m_pc, spot.m_count);
// move everything else down and insert this one at the top
- memmove(&m_hotspots[1], &m_hotspots[0], sizeof(m_hotspots[0]) * (m_hotspot_count - 1));
+ memmove(&m_hotspots[1], &m_hotspots[0], sizeof(m_hotspots[0]) * (m_hotspots.count() - 1));
m_hotspots[0].m_access = address;
m_hotspots[0].m_pc = curpc;
m_hotspots[0].m_space = &space;
diff --git a/src/emu/debug/debugcpu.h b/src/emu/debug/debugcpu.h
index 7ccde1eb05b..75f7c6b0b33 100644
--- a/src/emu/debug/debugcpu.h
+++ b/src/emu/debug/debugcpu.h
@@ -366,8 +366,7 @@ private:
address_space * m_space; // space where the access occurred
UINT32 m_count; // number of hits
};
- hotspot_entry * m_hotspots; // hotspot list
- int m_hotspot_count; // number of hotspots
+ dynamic_array<hotspot_entry> m_hotspots; // hotspot list
int m_hotspot_threshhold; // threshhold for the number of hits to print
// pc tracking
diff --git a/src/emu/debug/debugvw.c b/src/emu/debug/debugvw.c
index 44e5766224d..6d4ff66056c 100644
--- a/src/emu/debug/debugvw.c
+++ b/src/emu/debug/debugvw.c
@@ -194,13 +194,9 @@ debug_view::debug_view(running_machine &machine, debug_view_type type, debug_vie
m_update_level(0),
m_update_pending(true),
m_osd_update_pending(true),
- m_viewdata(NULL),
- m_viewdata_size(0),
+ m_viewdata(m_visible.y * m_visible.x),
m_machine(machine)
{
- // allocate memory for the buffer
- m_viewdata_size = m_visible.y * m_visible.x;
- m_viewdata = auto_alloc_array(machine, debug_view_char, m_viewdata_size);
}
@@ -230,13 +226,7 @@ void debug_view::end_update()
m_osd_update_pending = true;
// resize the viewdata if needed
- int size = m_visible.x * m_visible.y;
- if (size > m_viewdata_size)
- {
- m_viewdata_size = size;
- auto_free(machine(), m_viewdata);
- m_viewdata = auto_alloc_array(machine(), debug_view_char, m_viewdata_size);
- }
+ m_viewdata.resize(m_visible.x * m_visible.y);
// update the view
view_update();
diff --git a/src/emu/debug/debugvw.h b/src/emu/debug/debugvw.h
index ef8a86d33a5..50f84dd6b57 100644
--- a/src/emu/debug/debugvw.h
+++ b/src/emu/debug/debugvw.h
@@ -244,8 +244,7 @@ protected:
UINT8 m_update_level; // update level; updates when this hits 0
bool m_update_pending; // true if there is a pending update
bool m_osd_update_pending; // true if there is a pending update
- debug_view_char * m_viewdata; // current array of view data
- int m_viewdata_size; // number of elements of the viewdata array
+ dynamic_array<debug_view_char> m_viewdata; // current array of view data
private:
running_machine & m_machine; // machine associated with this view
diff --git a/src/emu/debug/dvdisasm.c b/src/emu/debug/dvdisasm.c
index b34865f7737..ef65d329c71 100644
--- a/src/emu/debug/dvdisasm.c
+++ b/src/emu/debug/dvdisasm.c
@@ -53,10 +53,7 @@ debug_view_disasm::debug_view_disasm(running_machine &machine, debug_view_osd_up
m_divider1(0),
m_divider2(0),
m_divider3(0),
- m_expression(machine),
- m_allocated(0,0),
- m_byteaddress(NULL),
- m_dasm(NULL)
+ m_expression(machine)
{
// fail if no available sources
enumerate_sources();
@@ -83,8 +80,6 @@ debug_view_disasm::debug_view_disasm(running_machine &machine, debug_view_osd_up
debug_view_disasm::~debug_view_disasm()
{
- auto_free(machine(), m_byteaddress);
- auto_free(machine(), m_dasm);
}
@@ -172,7 +167,7 @@ void debug_view_disasm::view_char(int chval)
offs_t pc = source.m_space.address_to_byte(source.m_device.safe_pc()) & source.m_space.logbytemask();
// figure out which row the pc is on
- for (int curline = 0; curline < m_allocated.y; curline++)
+ for (int curline = 0; curline < m_byteaddress.count(); curline++)
if (m_byteaddress[curline] == pc)
m_cursor.y = curline;
break;
@@ -364,22 +359,14 @@ bool debug_view_disasm::recompute(offs_t pc, int startline, int lines)
else
m_total.x = m_divider2 + 1;
- // reallocate memory if we don't have enough
- if (m_allocated.x < m_total.x || m_allocated.y < m_total.y)
- {
- // update our values
- m_allocated = m_total;
-
- // allocate address array
- auto_free(machine(), m_byteaddress);
- m_byteaddress = auto_alloc_array(machine(), offs_t, m_allocated.y);
+ // allocate address array
+ m_byteaddress.resize(m_total.y);
- // allocate disassembly buffer
- auto_free(machine(), m_dasm);
- m_dasm = auto_alloc_array(machine(), char, m_allocated.x * m_allocated.y);
- }
+ // allocate disassembly buffer
+ m_dasm.resize(m_total.x * m_total.y);
// iterate over lines
+ int row_width = m_total.x;
for (int line = 0; line < lines; line++)
{
// convert PC to a byte offset
@@ -387,10 +374,10 @@ bool debug_view_disasm::recompute(offs_t pc, int startline, int lines)
// save a copy of the previous line as a backup if we're only doing one line
int instr = startline + line;
- char *destbuf = &m_dasm[instr * m_allocated.x];
+ char *destbuf = &m_dasm[instr * row_width];
char oldbuf[100];
if (lines == 1)
- strncpy(oldbuf, destbuf, MIN(sizeof(oldbuf), m_allocated.x));
+ strncpy(oldbuf, destbuf, MIN(sizeof(oldbuf), row_width));
// convert back and set the address of this instruction
m_byteaddress[instr] = pcbyte;
@@ -425,7 +412,7 @@ bool debug_view_disasm::recompute(offs_t pc, int startline, int lines)
{
// get the bytes
numbytes = source.m_space.address_to_byte(numbytes) & source.m_space.logbytemask();
- generate_bytes(pcbyte, numbytes, minbytes, &destbuf[m_divider2], m_allocated.x - m_divider2, m_right_column == DASM_RIGHTCOL_ENCRYPTED);
+ generate_bytes(pcbyte, numbytes, minbytes, &destbuf[m_divider2], row_width - m_divider2, m_right_column == DASM_RIGHTCOL_ENCRYPTED);
}
else if (m_right_column == DASM_RIGHTCOL_COMMENTS)
{
@@ -433,11 +420,11 @@ bool debug_view_disasm::recompute(offs_t pc, int startline, int lines)
offs_t comment_address = source.m_space.byte_to_address(m_byteaddress[instr]);
const char *text = source.m_device.debug()->comment_text(comment_address);
if (text != NULL)
- sprintf(&destbuf[m_divider2], "// %.*s", m_allocated.x - m_divider2 - 1, text);
+ sprintf(&destbuf[m_divider2], "// %.*s", row_width - m_divider2 - 1, text);
}
// see if the line changed at all
- if (lines == 1 && strncmp(oldbuf, destbuf, MIN(sizeof(oldbuf), m_allocated.x)) != 0)
+ if (lines == 1 && strncmp(oldbuf, destbuf, MIN(sizeof(oldbuf), row_width)) != 0)
changed = true;
}
@@ -477,12 +464,12 @@ void debug_view_disasm::view_update()
// see if the new result is an address we already have
UINT32 row;
- for (row = 0; row < m_allocated.y; row++)
+ for (row = 0; row < m_byteaddress.count(); row++)
if (m_byteaddress[row] == resultbyte)
break;
// if we didn't find it, or if it's really close to the bottom, recompute
- if (row == m_allocated.y || row >= m_total.y - m_visible.y)
+ if (row == m_byteaddress.count() || row >= m_total.y - m_visible.y)
m_recompute = true;
// otherwise, if it's not visible, adjust the view so it is
@@ -504,7 +491,7 @@ recompute:
if (m_recompute)
{
// recompute the view
- if (m_byteaddress != NULL && m_last_change_count != source.m_device.debug()->comment_change_count())
+ if (m_byteaddress.count() > 0 && m_last_change_count != source.m_device.debug()->comment_change_count())
{
// smoosh us against the left column, but not the top row
m_topleft.x = 0;
@@ -533,7 +520,7 @@ recompute:
for (UINT32 row = 0; row < m_visible.y; row++)
{
UINT32 effrow = m_topleft.y + row;
- if (effrow >= m_allocated.y)
+ if (effrow >= m_byteaddress.count())
break;
if (pcbyte == m_byteaddress[effrow])
{
@@ -555,6 +542,7 @@ recompute:
// loop over visible rows
debug_view_char *dest = m_viewdata;
+ int row_width = m_dasm.count() / m_byteaddress.count();
for (UINT32 row = 0; row < m_visible.y; row++)
{
UINT32 effrow = m_topleft.y + row;
@@ -562,7 +550,7 @@ recompute:
// if this visible row is valid, add it to the buffer
UINT8 attrib = DCA_NORMAL;
- if (effrow < m_allocated.y)
+ if (effrow < m_byteaddress.count())
{
// if we're on the line with the PC, recompute and hilight it
if (pcbyte == m_byteaddress[effrow])
@@ -585,7 +573,7 @@ recompute:
attrib |= DCA_VISITED;
// get the effective string
- const char *data = &m_dasm[effrow * m_allocated.x];
+ const char *data = &m_dasm[effrow * row_width];
UINT32 len = (UINT32)strlen(data);
// copy data
diff --git a/src/emu/debug/dvdisasm.h b/src/emu/debug/dvdisasm.h
index dedec76d6a7..2eee80c32f8 100644
--- a/src/emu/debug/dvdisasm.h
+++ b/src/emu/debug/dvdisasm.h
@@ -104,9 +104,8 @@ private:
int m_divider1, m_divider2; // left and right divider columns
int m_divider3; // comment divider column
debug_view_expression m_expression; // expression-related information
- debug_view_xy m_allocated; // allocated rows/columns
- offs_t * m_byteaddress; // addresses of the instructions
- char * m_dasm; // disassembled instructions
+ dynamic_array<offs_t> m_byteaddress; // addresses of the instructions
+ dynamic_array<char> m_dasm; // disassembled instructions
// constants
static const int DEFAULT_DASM_LINES = 1000;
diff --git a/src/emu/ioport.c b/src/emu/ioport.c
index d31e432dff3..146ebf81e5a 100644
--- a/src/emu/ioport.c
+++ b/src/emu/ioport.c
@@ -1326,7 +1326,7 @@ void natural_keyboard::internal_post(unicode_char ch)
// add to the buffer, resizing if necessary
m_buffer[m_bufend++] = ch;
if ((m_bufend + 1) % m_buffer.count() == m_bufbegin)
- m_buffer.resize(m_buffer.count() + KEY_BUFFER_SIZE, true);
+ m_buffer.resize_keep(m_buffer.count() + KEY_BUFFER_SIZE);
m_bufend %= m_buffer.count();
}
diff --git a/src/emu/machine/7200fifo.c b/src/emu/machine/7200fifo.c
index 1794d4ce737..c8bce39184c 100644
--- a/src/emu/machine/7200fifo.c
+++ b/src/emu/machine/7200fifo.c
@@ -37,7 +37,7 @@ fifo7200_device::fifo7200_device(const machine_config &mconfig, const char *tag,
void fifo7200_device::device_start()
{
assert(m_ram_size > 1 && ~m_ram_size & 1);
- m_buffer = auto_alloc_array(machine(), UINT16, m_ram_size);
+ m_buffer.resize(m_ram_size);
// resolve callbacks
m_ef_handler.resolve();
@@ -59,7 +59,7 @@ void fifo7200_device::device_start()
void fifo7200_device::device_reset()
{
// master reset
- memset(m_buffer, 0, m_ram_size * sizeof(UINT16));
+ m_buffer.clear();
m_read_ptr = 0;
m_write_ptr = 0;
diff --git a/src/emu/machine/7200fifo.h b/src/emu/machine/7200fifo.h
index 4ff1a0d17c9..999f25e6c7f 100644
--- a/src/emu/machine/7200fifo.h
+++ b/src/emu/machine/7200fifo.h
@@ -113,7 +113,7 @@ private:
void fifo_write(UINT16 data);
UINT16 fifo_read();
- UINT16* m_buffer;
+ dynamic_array<UINT16> m_buffer;
int m_ram_size;
int m_read_ptr;
diff --git a/src/emu/machine/at28c16.c b/src/emu/machine/at28c16.c
index 2b9d0b6d985..1a797c12a51 100644
--- a/src/emu/machine/at28c16.c
+++ b/src/emu/machine/at28c16.c
@@ -145,7 +145,7 @@ void at28c16_device::nvram_default()
void at28c16_device::nvram_read( emu_file &file )
{
- UINT8 *buffer = auto_alloc_array( machine(), UINT8, AT28C16_TOTAL_BYTES );
+ dynamic_buffer buffer( AT28C16_TOTAL_BYTES );
file.read( buffer, AT28C16_TOTAL_BYTES );
@@ -153,8 +153,6 @@ void at28c16_device::nvram_read( emu_file &file )
{
m_addrspace[ 0 ]->write_byte( offs, buffer[ offs ] );
}
-
- auto_free( machine(), buffer );
}
//-------------------------------------------------
@@ -164,7 +162,7 @@ void at28c16_device::nvram_read( emu_file &file )
void at28c16_device::nvram_write( emu_file &file )
{
- UINT8 *buffer = auto_alloc_array( machine(), UINT8, AT28C16_TOTAL_BYTES );
+ dynamic_buffer buffer ( AT28C16_TOTAL_BYTES );
for( offs_t offs = 0; offs < AT28C16_TOTAL_BYTES; offs++ )
{
@@ -172,8 +170,6 @@ void at28c16_device::nvram_write( emu_file &file )
}
file.write( buffer, AT28C16_TOTAL_BYTES );
-
- auto_free( machine(), buffer );
}
diff --git a/src/emu/machine/at45dbxx.c b/src/emu/machine/at45dbxx.c
index fea7b59fc69..27d4ca3b72a 100644
--- a/src/emu/machine/at45dbxx.c
+++ b/src/emu/machine/at45dbxx.c
@@ -76,12 +76,12 @@ at45db161_device::at45db161_device(const machine_config &mconfig, const char *ta
void at45db041_device::device_start()
{
m_size = num_pages() * page_size();
- m_data = auto_alloc_array(machine(), UINT8, m_size);
- m_buffer1 = auto_alloc_array(machine(), UINT8, page_size());
- //m_buffer2 = auto_alloc_array(machine(), UINT8, page_size());
+ m_data.resize(m_size);
+ m_buffer1.resize(page_size());
+ //m_buffer2.resize(page_size());
// data
- save_pointer(NAME(m_data), m_size);
+ save_item(NAME(m_data));
// pins
save_item(NAME(m_pin.cs));
save_item(NAME(m_pin.sck));
@@ -134,7 +134,7 @@ void at45db041_device::device_reset()
void at45db041_device::nvram_default()
{
- memset(m_data, 0xff, m_size);
+ m_data.clear(0xff);
if (region() != NULL)
{
@@ -284,7 +284,7 @@ void at45db041_device::write_byte(UINT8 data)
byte = flash_get_byte_addr();
_logerror( 1, ("at45dbxx opcode %02X - main memory page program through buffer 1 [%04X/%04X]\n",opcode, page, byte));
flash_set_io(m_buffer1, page_size(), byte);
- memset( m_buffer1, 0xFF, page_size());
+ m_buffer1.clear(0xFF);
m_mode = FLASH_MODE_SI;
m_cmd.size = 8;
}
diff --git a/src/emu/machine/at45dbxx.h b/src/emu/machine/at45dbxx.h
index 9568068a9a6..c90487f6e62 100644
--- a/src/emu/machine/at45dbxx.h
+++ b/src/emu/machine/at45dbxx.h
@@ -68,12 +68,12 @@ protected:
void write_byte(UINT8 data);
// internal state
- UINT8 * m_data;
+ dynamic_buffer m_data;
UINT32 m_size;
UINT8 m_mode;
UINT8 m_status;
- UINT8 * m_buffer1;
- //UINT8 * m_buffer2;
+ dynamic_buffer m_buffer1;
+ //dynamic_buffer m_buffer2;
UINT8 m_si_byte;
UINT8 m_si_bits;
UINT8 m_so_byte;
diff --git a/src/emu/machine/atahle.c b/src/emu/machine/atahle.c
index a767d51cc02..46ba79a379a 100644
--- a/src/emu/machine/atahle.c
+++ b/src/emu/machine/atahle.c
@@ -78,8 +78,8 @@ void ata_hle_device::device_start()
m_dasp_handler.resolve_safe();
m_pdiag_handler.resolve_safe();
- m_buffer = auto_alloc_array(machine(), UINT8, sector_length());
- save_pointer(NAME(m_buffer), sector_length());
+ m_buffer.resize(sector_length());
+ save_item(NAME(m_buffer));
save_item(NAME(m_buffer_offset));
save_item(NAME(m_error));
save_item(NAME(m_feature));
diff --git a/src/emu/machine/atahle.h b/src/emu/machine/atahle.h
index be9df68b060..eb7477caabe 100644
--- a/src/emu/machine/atahle.h
+++ b/src/emu/machine/atahle.h
@@ -174,7 +174,7 @@ protected:
attotime MINIMUM_COMMAND_TIME;
- UINT8 *m_buffer;
+ dynamic_buffer m_buffer;
UINT16 m_buffer_offset;
UINT16 m_buffer_size;
UINT8 m_error;
diff --git a/src/emu/machine/i2cmem.c b/src/emu/machine/i2cmem.c
index a3f7734bc31..71b16b1763d 100644
--- a/src/emu/machine/i2cmem.c
+++ b/src/emu/machine/i2cmem.c
@@ -120,10 +120,7 @@ void i2cmem_device::device_config_complete()
void i2cmem_device::device_start()
{
- if( m_page_size > 0 )
- {
- m_page = auto_alloc_array( machine(), UINT8, m_page_size );
- }
+ m_page.resize( m_page_size );
save_item( NAME(m_scl) );
save_item( NAME(m_sdaw) );
@@ -137,7 +134,7 @@ void i2cmem_device::device_start()
save_item( NAME(m_shift) );
save_item( NAME(m_devsel) );
save_item( NAME(m_byteaddr) );
- save_pointer( NAME(m_page), m_page_size );
+ save_item( NAME(m_page) );
}
@@ -205,7 +202,7 @@ void i2cmem_device::nvram_default()
void i2cmem_device::nvram_read( emu_file &file )
{
int i2cmem_bytes = m_data_size;
- UINT8 *buffer = auto_alloc_array( machine(), UINT8, i2cmem_bytes );
+ dynamic_buffer buffer ( i2cmem_bytes );
file.read( buffer, i2cmem_bytes );
@@ -213,8 +210,6 @@ void i2cmem_device::nvram_read( emu_file &file )
{
m_addrspace[ 0 ]->write_byte( offs, buffer[ offs ] );
}
-
- auto_free( machine(), buffer );
}
//-------------------------------------------------
@@ -225,7 +220,7 @@ void i2cmem_device::nvram_read( emu_file &file )
void i2cmem_device::nvram_write( emu_file &file )
{
int i2cmem_bytes = m_data_size;
- UINT8 *buffer = auto_alloc_array( machine(), UINT8, i2cmem_bytes );
+ dynamic_buffer buffer ( i2cmem_bytes );
for( offs_t offs = 0; offs < i2cmem_bytes; offs++ )
{
@@ -233,8 +228,6 @@ void i2cmem_device::nvram_write( emu_file &file )
}
file.write( buffer, i2cmem_bytes );
-
- auto_free( machine(), buffer );
}
diff --git a/src/emu/machine/i2cmem.h b/src/emu/machine/i2cmem.h
index 2a814917fb1..58d665e59a1 100644
--- a/src/emu/machine/i2cmem.h
+++ b/src/emu/machine/i2cmem.h
@@ -147,7 +147,7 @@ protected:
int m_shift;
int m_devsel;
int m_byteaddr;
- UINT8 *m_page;
+ dynamic_buffer m_page;
int m_page_offset;
};
diff --git a/src/emu/machine/k033906.c b/src/emu/machine/k033906.c
index 3c859d8981a..ff9d091e53c 100644
--- a/src/emu/machine/k033906.c
+++ b/src/emu/machine/k033906.c
@@ -56,13 +56,10 @@ void k033906_device::device_start()
{
m_voodoo = machine().device(m_voodoo_tag);
- m_reg = auto_alloc_array(machine(), UINT32, 256);
- m_ram = auto_alloc_array(machine(), UINT32, 32768);
-
m_reg_set = 0;
- save_pointer(NAME(m_reg), 256);
- save_pointer(NAME(m_ram), 32768);
+ save_item(NAME(m_reg));
+ save_item(NAME(m_ram));
save_item(NAME(m_reg_set));
}
diff --git a/src/emu/machine/k033906.h b/src/emu/machine/k033906.h
index 1e526bed7c1..dce11e2bcbd 100644
--- a/src/emu/machine/k033906.h
+++ b/src/emu/machine/k033906.h
@@ -63,12 +63,13 @@ private:
void k033906_reg_w(int reg, UINT32 data);
/* i/o lines */
- UINT32 * m_reg;
- UINT32 * m_ram;
int m_reg_set; // 1 = access reg / 0 = access ram
device_t *m_voodoo;
+
+ UINT32 m_reg[256];
+ UINT32 m_ram[32768];
};
diff --git a/src/emu/machine/k056230.c b/src/emu/machine/k056230.c
index acf86c95b2c..eb45cd366b6 100644
--- a/src/emu/machine/k056230.c
+++ b/src/emu/machine/k056230.c
@@ -64,9 +64,7 @@ void k056230_device::device_start()
m_cpu = NULL;
}
- m_ram = auto_alloc_array(machine(), UINT32, 0x2000);
-
- save_pointer(NAME(m_ram), 0x2000);
+ save_item(NAME(m_ram));
}
diff --git a/src/emu/machine/k056230.h b/src/emu/machine/k056230.h
index 17763ef87ad..4084140cb9f 100644
--- a/src/emu/machine/k056230.h
+++ b/src/emu/machine/k056230.h
@@ -66,8 +66,8 @@ private:
void network_irq_clear();
- UINT32 *m_ram;
device_t *m_cpu;
+ UINT32 m_ram[0x2000];
};
diff --git a/src/emu/machine/laserdsc.c b/src/emu/machine/laserdsc.c
index ff56d02bec5..1cce9402429 100644
--- a/src/emu/machine/laserdsc.c
+++ b/src/emu/machine/laserdsc.c
@@ -844,8 +844,8 @@ void laserdisc_device::init_audio()
// allocate audio buffers
m_audiomaxsamples = ((UINT64)m_samplerate * 1000000 + m_fps_times_1million - 1) / m_fps_times_1million;
m_audiobufsize = m_audiomaxsamples * 4;
- m_audiobuffer[0] = auto_alloc_array(machine(), INT16, m_audiobufsize);
- m_audiobuffer[1] = auto_alloc_array(machine(), INT16, m_audiobufsize);
+ m_audiobuffer[0].resize(m_audiobufsize);
+ m_audiobuffer[1].resize(m_audiobufsize);
}
diff --git a/src/emu/machine/laserdsc.h b/src/emu/machine/laserdsc.h
index e0c991d482d..ec557af74bf 100644
--- a/src/emu/machine/laserdsc.h
+++ b/src/emu/machine/laserdsc.h
@@ -322,7 +322,7 @@ private:
// audio data
sound_stream * m_stream;
- INT16 * m_audiobuffer[2]; // buffer for audio samples
+ dynamic_array<INT16> m_audiobuffer[2]; // buffer for audio samples
UINT32 m_audiobufsize; // size of buffer
UINT32 m_audiobufin; // input index
UINT32 m_audiobufout; // output index
diff --git a/src/emu/machine/mc146818.c b/src/emu/machine/mc146818.c
index fdfc9ca2d16..95352f08cef 100644
--- a/src/emu/machine/mc146818.c
+++ b/src/emu/machine/mc146818.c
@@ -56,7 +56,7 @@ mc146818_device::mc146818_device(const machine_config &mconfig, device_type type
void mc146818_device::device_start()
{
- m_data= auto_alloc_array(machine(), UINT8, data_size());
+ m_data.resize(data_size());
m_last_refresh = machine().time();
m_clock_timer = timer_alloc(TIMER_CLOCK);
m_periodic_timer = timer_alloc(TIMER_PERIODIC);
@@ -194,7 +194,7 @@ void mc146818_device::nvram_default()
}
else
{
- memset(m_data, 0, data_size());
+ m_data.clear();
}
set_base_datetime();
diff --git a/src/emu/machine/mc146818.h b/src/emu/machine/mc146818.h
index fd0cab8f2d9..1529c9a0e9c 100644
--- a/src/emu/machine/mc146818.h
+++ b/src/emu/machine/mc146818.h
@@ -152,7 +152,7 @@ private:
// internal state
UINT8 m_index;
- UINT8 *m_data;
+ dynamic_buffer m_data;
attotime m_last_refresh;
diff --git a/src/emu/machine/ram.c b/src/emu/machine/ram.c
index 66085274f88..c811266e1f8 100644
--- a/src/emu/machine/ram.c
+++ b/src/emu/machine/ram.c
@@ -34,7 +34,6 @@ ram_device::ram_device(const machine_config &mconfig, const char *tag, device_t
: device_t(mconfig, RAM, "RAM", tag, owner, clock, "ram", __FILE__)
{
m_size = 0;
- m_pointer = NULL;
m_default_size = NULL;
m_extra_options = NULL;
m_default_value = 0xCD;
@@ -62,14 +61,11 @@ void ram_device::device_start()
m_size = default_size();
/* allocate space for the ram */
- m_pointer = auto_alloc_array(machine(), UINT8, m_size);
-
- /* reset ram to the default value */
- memset(m_pointer, m_default_value, m_size);
+ m_pointer.resize_and_clear(m_size, m_default_value);
/* register for state saving */
save_item(NAME(m_size));
- save_pointer(NAME(m_pointer), m_size);
+ save_item(NAME(m_pointer));
}
diff --git a/src/emu/machine/ram.h b/src/emu/machine/ram.h
index 7579c730a6e..a1d34805c45 100644
--- a/src/emu/machine/ram.h
+++ b/src/emu/machine/ram.h
@@ -57,7 +57,7 @@ public:
// accessors
UINT32 size(void) const { return m_size; }
UINT32 mask(void) const { return m_size - 1; }
- UINT8 *pointer(void) const { return m_pointer; }
+ UINT8 *pointer(void) { return m_pointer; }
static UINT32 parse_string(const char *s);
UINT32 default_size(void) const;
const char *extra_options(void) const { return m_extra_options; }
@@ -78,7 +78,7 @@ protected:
private:
// device state
UINT32 m_size;
- UINT8 *m_pointer;
+ dynamic_buffer m_pointer;
// device config
const char *m_default_size;
diff --git a/src/emu/machine/s2636.c b/src/emu/machine/s2636.c
index 121ed6e87ca..e7da0e3fff4 100644
--- a/src/emu/machine/s2636.c
+++ b/src/emu/machine/s2636.c
@@ -91,9 +91,6 @@ s2636_device::s2636_device(const machine_config &mconfig, const char *tag, devic
: device_t(mconfig, S2636, "Signetics 2636", tag, owner, clock, "s2636", __FILE__),
device_video_interface(mconfig, *this),
device_sound_interface(mconfig, *this),
- m_work_ram(NULL),
- m_bitmap(NULL),
- m_collision_bitmap(NULL),
m_channel(NULL),
m_size(0),
m_pos(0),
@@ -134,15 +131,15 @@ void s2636_device::device_start()
int width = m_screen->width();
int height = m_screen->height();
- m_work_ram = auto_alloc_array_clear(machine(), UINT8, m_work_ram_size);
- m_bitmap = auto_bitmap_ind16_alloc(machine(), width, height);
- m_collision_bitmap = auto_bitmap_ind16_alloc(machine(), width, height);
+ m_work_ram.resize_and_clear(m_work_ram_size);
+ m_bitmap.resize(width, height);
+ m_collision_bitmap.resize(width, height);
save_item(NAME(m_x_offset));
save_item(NAME(m_y_offset));
- save_pointer(NAME(m_work_ram), m_work_ram_size);
- save_item(NAME(*m_bitmap));
- save_item(NAME(*m_collision_bitmap));
+ save_item(NAME(m_work_ram));
+ save_item(NAME(m_bitmap));
+ save_item(NAME(m_collision_bitmap));
m_channel = machine().sound().stream_alloc(*this, 0, 1, machine().sample_rate(), this);
@@ -232,7 +229,7 @@ int s2636_device::check_collision( int spriteno1, int spriteno2, const rectangle
/* TODO: does not check shadow sprites yet */
- m_collision_bitmap->fill(0, cliprect);
+ m_collision_bitmap.fill(0, cliprect);
if ((attr1[0x0a] != 0xff) && (attr2[0x0a] != 0xff))
{
@@ -247,7 +244,7 @@ int s2636_device::check_collision( int spriteno1, int spriteno2, const rectangle
int expand2 = (m_work_ram[0xc0] >> (spriteno2 << 1)) & 0x03;
/* draw first sprite */
- draw_sprite(attr1, 1, y1, x1, expand1, FALSE, *m_collision_bitmap, cliprect);
+ draw_sprite(attr1, 1, y1, x1, expand1, FALSE, m_collision_bitmap, cliprect);
/* get fingerprint */
for (x = x1; x < x1 + SPRITE_WIDTH; x++)
@@ -256,11 +253,11 @@ int s2636_device::check_collision( int spriteno1, int spriteno2, const rectangle
if (!cliprect.contains(x, y))
continue;
- checksum = checksum + m_collision_bitmap->pix16(y, x);
+ checksum = checksum + m_collision_bitmap.pix16(y, x);
}
/* black out second sprite */
- draw_sprite(attr2, 0, y2, x2, expand2, FALSE, *m_collision_bitmap, cliprect);
+ draw_sprite(attr2, 0, y2, x2, expand2, FALSE, m_collision_bitmap, cliprect);
/* remove fingerprint */
for (x = x1; x < x1 + SPRITE_WIDTH; x++)
@@ -269,7 +266,7 @@ int s2636_device::check_collision( int spriteno1, int spriteno2, const rectangle
if (!cliprect.contains(x, y))
continue;
- checksum = checksum - m_collision_bitmap->pix16(y, x);
+ checksum = checksum - m_collision_bitmap.pix16(y, x);
}
}
@@ -289,7 +286,7 @@ bitmap_ind16 &s2636_device::update( const rectangle &cliprect )
UINT8 collision = 0;
int spriteno;
- m_bitmap->fill(0, cliprect);
+ m_bitmap.fill(0, cliprect);
for (spriteno = 0; spriteno < 4; spriteno++)
{
@@ -306,7 +303,7 @@ bitmap_ind16 &s2636_device::update( const rectangle &cliprect )
color = (m_work_ram[0xc1 + (spriteno >> 1)] >> ((spriteno & 1) ? 0 : 3)) & 0x07;
expand = (m_work_ram[0xc0] >> (spriteno << 1)) & 0x03;
- draw_sprite(attr, color, y, x, expand, TRUE, *m_bitmap, cliprect);
+ draw_sprite(attr, color, y, x, expand, TRUE, m_bitmap, cliprect);
/* bail if no shadow sprites */
if ((attr[0x0b] == 0xff) || (attr[0x0d] == 0xfe))
@@ -318,7 +315,7 @@ bitmap_ind16 &s2636_device::update( const rectangle &cliprect )
{
y = y + SPRITE_HEIGHT + attr[0x0d];
- draw_sprite(attr, color, y, x, expand, TRUE, *m_bitmap, cliprect);
+ draw_sprite(attr, color, y, x, expand, TRUE, m_bitmap, cliprect);
}
}
@@ -332,7 +329,7 @@ bitmap_ind16 &s2636_device::update( const rectangle &cliprect )
m_work_ram[0xcb] = collision;
- return *m_bitmap;
+ return m_bitmap;
}
diff --git a/src/emu/machine/s2636.h b/src/emu/machine/s2636.h
index 112fe5f9913..67d59650af6 100644
--- a/src/emu/machine/s2636.h
+++ b/src/emu/machine/s2636.h
@@ -60,9 +60,9 @@ protected:
private:
// internal state
- UINT8 *m_work_ram;
- bitmap_ind16 *m_bitmap;
- bitmap_ind16 *m_collision_bitmap;
+ dynamic_buffer m_work_ram;
+ bitmap_ind16 m_bitmap;
+ bitmap_ind16 m_collision_bitmap;
sound_stream *m_channel;
UINT8 m_reg[1];
diff --git a/src/emu/machine/serflash.c b/src/emu/machine/serflash.c
index c1346b1f9bf..ba3b4f83da9 100644
--- a/src/emu/machine/serflash.c
+++ b/src/emu/machine/serflash.c
@@ -37,8 +37,7 @@ void serflash_device::device_start()
m_length = machine().root_device().memregion( tag() )->bytes();
m_region = machine().root_device().memregion( tag() )->base();
- m_flashwritemap = auto_alloc_array(machine(), UINT8, m_length / FLASH_PAGE_SIZE);
- memset(m_flashwritemap, 0, m_length / FLASH_PAGE_SIZE);
+ m_flashwritemap.resize_and_clear(m_length / FLASH_PAGE_SIZE);
}
diff --git a/src/emu/machine/serflash.h b/src/emu/machine/serflash.h
index e4045a78582..8f37e6d6ca5 100644
--- a/src/emu/machine/serflash.h
+++ b/src/emu/machine/serflash.h
@@ -86,7 +86,7 @@ protected:
UINT16 m_flash_page_index;
- UINT8* m_flashwritemap;
+ dynamic_buffer m_flashwritemap;
UINT8 m_last_flash_cmd;
diff --git a/src/emu/machine/stvcd.c b/src/emu/machine/stvcd.c
index c516c9b7037..0a1dacc958e 100644
--- a/src/emu/machine/stvcd.c
+++ b/src/emu/machine/stvcd.c
@@ -1429,9 +1429,7 @@ void saturn_state::stvcd_reset( void )
cd_stat |= CD_STAT_PERI;
cur_track = 0xff;
- if (curdir != (direntryT *)NULL)
- auto_free(machine(), curdir);
- curdir = (direntryT *)NULL; // no directory yet
+ curdir.reset();
xfertype = XFERTYPE_INVALID;
xfertype32 = XFERTYPE32_INVALID;
@@ -2167,12 +2165,7 @@ void saturn_state::make_dir_current(UINT32 fad)
}
}
- if (curdir != (direntryT *)NULL)
- {
- auto_free(machine(), curdir);
- }
-
- curdir = auto_alloc_array(machine(), direntryT, numentries);
+ curdir.resize(numentries);
curentry = curdir;
numfiles = numentries;
@@ -2243,11 +2236,7 @@ void saturn_state::make_dir_current(UINT32 fad)
void saturn_state::stvcd_exit( void )
{
- if (curdir != (direntryT *)NULL)
- {
- auto_free(machine(), curdir);
- curdir = (direntryT *)NULL;
- }
+ curdir.reset();
if (cdrom)
{
diff --git a/src/emu/machine/tc009xlvc.c b/src/emu/machine/tc009xlvc.c
index beda58b97af..c80c38b2f11 100644
--- a/src/emu/machine/tc009xlvc.c
+++ b/src/emu/machine/tc009xlvc.c
@@ -256,21 +256,20 @@ static const gfx_layout char_layout =
void tc0091lvc_device::device_start()
{
- m_palette_ram = auto_alloc_array_clear(machine(), UINT8, 0x200);
- m_vregs = auto_alloc_array_clear(machine(), UINT8, 0x100);
- m_bitmap_ram = auto_alloc_array_clear(machine(), UINT8, 0x20000);
+ memset(m_palette_ram, 0, sizeof(m_palette_ram));
+ memset(m_vregs, 0, sizeof(m_palette_ram));
+ memset(m_bitmap_ram, 0, sizeof(m_palette_ram));
+ memset(m_pcg_ram, 0, sizeof(m_pcg_ram));
+ memset(m_sprram_buffer, 0, sizeof(m_sprram_buffer));
// note, the way tiles are addressed suggests that 0x0000-0x3fff of this might be usable,
// but we don't map it anywhere, so the first tiles are always blank at the moment.
- m_pcg_ram = auto_alloc_array_clear(machine(), UINT8, 0x10000);
-
m_pcg1_ram = m_pcg_ram + 0x4000;
m_pcg2_ram = m_pcg_ram + 0xc000;
m_vram0 = m_pcg_ram + 0x8000;
m_vram1 = m_pcg_ram + 0x9000;
m_tvram = m_pcg_ram + 0xa000;
m_sprram = m_pcg_ram + 0xb000;
- m_sprram_buffer = auto_alloc_array_clear(machine(), UINT8, 0x400);
tx_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(tc0091lvc_device::get_tx_tile_info),this),TILEMAP_SCAN_ROWS,8,8,64,32);
bg0_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(tc0091lvc_device::get_bg0_tile_info),this),TILEMAP_SCAN_ROWS,8,8,64,32);
diff --git a/src/emu/machine/tc009xlvc.h b/src/emu/machine/tc009xlvc.h
index 458ac613ddf..e374f7603e6 100644
--- a/src/emu/machine/tc009xlvc.h
+++ b/src/emu/machine/tc009xlvc.h
@@ -47,17 +47,11 @@ public:
TILE_GET_INFO_MEMBER(get_bg1_tile_info);
TILE_GET_INFO_MEMBER(get_tx_tile_info);
- UINT8 *m_palette_ram;
- UINT8 *m_vregs;
- UINT8 *m_bitmap_ram;
-
- UINT8 *m_pcg_ram;
UINT8 *m_pcg1_ram;
UINT8 *m_pcg2_ram;
UINT8 *m_vram0;
UINT8 *m_vram1;
UINT8 *m_sprram;
- UINT8 *m_sprram_buffer;
UINT8 *m_tvram;
UINT8 m_bg0_scroll[4];
UINT8 m_bg1_scroll[4];
@@ -68,6 +62,12 @@ public:
int m_gfx_index; // for RAM tiles
+ UINT8 m_palette_ram[0x200];
+ UINT8 m_vregs[0x100];
+ UINT8 m_bitmap_ram[0x20000];
+ UINT8 m_pcg_ram[0x10000];
+ UINT8 m_sprram_buffer[0x400];
+
UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
void draw_sprites( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8 global_flip);
void screen_eof(void);
diff --git a/src/emu/machine/timekpr.c b/src/emu/machine/timekpr.c
index 1ba33fd46d8..6c46a56efc4 100644
--- a/src/emu/machine/timekpr.c
+++ b/src/emu/machine/timekpr.c
@@ -226,7 +226,7 @@ void timekeeper_device::device_start()
m_month = make_bcd( systime.local_time.month + 1 );
m_year = make_bcd( systime.local_time.year % 100 );
m_century = make_bcd( systime.local_time.year / 100 );
- m_data = auto_alloc_array( machine(), UINT8, m_size );
+ m_data.resize( m_size );
m_default_data = *region();
if (m_default_data)
@@ -243,7 +243,7 @@ void timekeeper_device::device_start()
save_item( NAME(m_month) );
save_item( NAME(m_year) );
save_item( NAME(m_century) );
- save_pointer( NAME(m_data), m_size );
+ save_item( NAME(m_data) );
emu_timer *timer = timer_alloc();
timer->adjust(attotime::from_seconds(1), 0, attotime::from_seconds(1));
@@ -402,7 +402,7 @@ void timekeeper_device::nvram_default()
}
else
{
- memset( m_data, 0xff, m_size );
+ m_data.clear( 0xff );
}
if ( m_offset_flags >= 0 )
diff --git a/src/emu/machine/timekpr.h b/src/emu/machine/timekpr.h
index 89edfa409c8..ad5f51cae39 100644
--- a/src/emu/machine/timekpr.h
+++ b/src/emu/machine/timekpr.h
@@ -85,7 +85,7 @@ private:
UINT8 m_year;
UINT8 m_century;
- UINT8 *m_data;
+ dynamic_buffer m_data;
UINT8 *m_default_data;
protected:
diff --git a/src/emu/memory.c b/src/emu/memory.c
index ecc7a8247d3..e7bcd511994 100644
--- a/src/emu/memory.c
+++ b/src/emu/memory.c
@@ -619,7 +619,7 @@ public:
}
// enable watchpoints by swapping in the watchpoint table
- void enable_watchpoints(bool enable = true) { m_live_lookup = enable ? s_watchpoint_table : m_table; }
+ void enable_watchpoints(bool enable = true) { m_live_lookup = enable ? s_watchpoint_table : &m_table[0]; }
// table mapping helpers
void map_range(offs_t bytestart, offs_t byteend, offs_t bytemask, offs_t bytemirror, UINT16 staticentry);
@@ -651,7 +651,7 @@ protected:
UINT16 *subtable_ptr(UINT16 entry) { return &m_table[level2_index(entry, 0)]; }
// internal state
- UINT16 * m_table; // pointer to base of table
+ dynamic_array<UINT16> m_table; // pointer to base of table
UINT16 * m_live_lookup; // current lookup
address_space & m_space; // pointer back to the space
bool m_large; // large memory model?
@@ -669,7 +669,7 @@ protected:
UINT32 m_checksum; // checksum over all the bytes
UINT32 m_usecount; // number of times this has been used
};
- subtable_data * m_subtable; // info about each subtable
+ dynamic_array<subtable_data> m_subtable; // info about each subtable
UINT16 m_subtable_alloc; // number of subtables allocated
// static global read-only watchpoint table
@@ -2899,11 +2899,11 @@ memory_bank &address_space::bank_find_or_allocate(const char *tag, offs_t addrst
//-------------------------------------------------
address_table::address_table(address_space &space, bool large)
- : m_table(auto_alloc_array(space.machine(), UINT16, 1 << LEVEL1_BITS)),
+ : m_table(1 << LEVEL1_BITS),
m_live_lookup(m_table),
m_space(space),
m_large(large),
- m_subtable(auto_alloc_array(space.machine(), subtable_data, SUBTABLE_COUNT)),
+ m_subtable(SUBTABLE_COUNT),
m_subtable_alloc(0)
{
// make our static table all watchpoints
@@ -2932,8 +2932,6 @@ address_table::address_table(address_space &space, bool large)
address_table::~address_table()
{
- auto_free(m_space.machine(), m_table);
- auto_free(m_space.machine(), m_subtable);
}
@@ -3494,16 +3492,13 @@ UINT16 address_table::subtable_alloc()
// if this is past our allocation budget, allocate some more
if (subindex >= m_subtable_alloc)
{
- UINT32 oldsize = (1 << LEVEL1_BITS) + (m_subtable_alloc << level2_bits());
m_subtable_alloc += SUBTABLE_ALLOC;
UINT32 newsize = (1 << LEVEL1_BITS) + (m_subtable_alloc << level2_bits());
- UINT16 *newtable = auto_alloc_array_clear(m_space.machine(), UINT16, newsize);
- memcpy(newtable, m_table, 2*oldsize);
- if (m_live_lookup == m_table)
- m_live_lookup = newtable;
- auto_free(m_space.machine(), m_table);
- m_table = newtable;
+ bool was_live = (m_live_lookup == m_table);
+ m_table.resize_keep_and_clear_new(newsize);
+ if (was_live)
+ m_live_lookup = m_table;
}
// bump the usecount and return
m_subtable[subindex].m_usecount++;
@@ -4091,11 +4086,14 @@ memory_block::memory_block(address_space &space, offs_t bytestart, offs_t byteen
{
offs_t length = byteend + 1 - bytestart;
if (length < 4096)
- m_allocated = m_data = auto_alloc_array_clear(space.machine(), UINT8, length);
+ {
+ m_allocated.resize_and_clear(length);
+ m_data = m_allocated;
+ }
else
{
- m_allocated = auto_alloc_array_clear(space.machine(), UINT8, length + 0xfff);
- m_data = reinterpret_cast<UINT8 *>((reinterpret_cast<FPTR>(m_allocated) + 0xfff) & ~0xfff);
+ m_allocated.resize_and_clear(length + 0xfff);
+ m_data = reinterpret_cast<UINT8 *>((reinterpret_cast<FPTR>(&m_allocated[0]) + 0xfff) & ~0xfff);
}
}
@@ -4125,8 +4123,6 @@ memory_block::memory_block(address_space &space, offs_t bytestart, offs_t byteen
memory_block::~memory_block()
{
- if (m_allocated != NULL)
- auto_free(machine(), m_allocated);
}
@@ -4148,9 +4144,7 @@ memory_bank::memory_bank(address_space &space, int index, offs_t bytestart, offs
m_anonymous(tag == NULL),
m_bytestart(bytestart),
m_byteend(byteend),
- m_curentry(BANK_ENTRY_UNSPECIFIED),
- m_entry(NULL),
- m_entry_count(0)
+ m_curentry(BANK_ENTRY_UNSPECIFIED)
{
// generate an internal tag if we don't have one
if (tag == NULL)
@@ -4264,7 +4258,7 @@ void memory_bank::set_entry(int entrynum)
// validate
if (m_anonymous)
throw emu_fatalerror("memory_bank::set_entry called for anonymous bank");
- if (entrynum < 0 || entrynum >= m_entry_count)
+ if (entrynum < 0 || entrynum >= m_entry.count())
throw emu_fatalerror("memory_bank::set_entry called with out-of-range entry %d", entrynum);
if (m_entry[entrynum].m_raw == NULL)
throw emu_fatalerror("memory_bank::set_entry called for bank '%s' with invalid bank entry %d", m_tag.cstr(), entrynum);
@@ -4286,17 +4280,8 @@ void memory_bank::set_entry(int entrynum)
void memory_bank::expand_entries(int entrynum)
{
- int newcount = entrynum + 1;
-
// allocate a new array and copy from the old one; zero out the new entries
- bank_entry *newentry = auto_alloc_array(machine(), bank_entry, newcount);
- memcpy(newentry, m_entry, sizeof(m_entry[0]) * m_entry_count);
- memset(&newentry[m_entry_count], 0, (newcount - m_entry_count) * sizeof(m_entry[0]));
-
- // free the old array and set the updated values
- auto_free(machine(), m_entry);
- m_entry = newentry;
- m_entry_count = newcount;
+ m_entry.resize_keep_and_clear_new(entrynum + 1);
}
@@ -4311,7 +4296,7 @@ void memory_bank::configure_entry(int entrynum, void *base)
throw emu_fatalerror("memory_bank::configure_entry called with out-of-range entry %d", entrynum);
// if we haven't allocated this many entries yet, expand our array
- if (entrynum >= m_entry_count)
+ if (entrynum >= m_entry.count())
expand_entries(entrynum);
// set the entry
@@ -4347,7 +4332,7 @@ void memory_bank::configure_decrypted_entry(int entrynum, void *base)
throw emu_fatalerror("memory_bank::configure_decrypted_entry called with out-of-range entry %d", entrynum);
// if we haven't allocated this many entries yet, expand our array
- if (entrynum >= m_entry_count)
+ if (entrynum >= m_entry.count())
expand_entries(entrynum);
// set the entry
diff --git a/src/emu/memory.h b/src/emu/memory.h
index 0c227b422d2..da956d4975f 100644
--- a/src/emu/memory.h
+++ b/src/emu/memory.h
@@ -598,7 +598,7 @@ private:
address_space & m_space; // which address space are we associated with?
offs_t m_bytestart, m_byteend; // byte-normalized start/end for verifying a match
UINT8 * m_data; // pointer to the data for this block
- UINT8 * m_allocated; // pointer to the actually allocated block
+ dynamic_buffer m_allocated; // pointer to the actually allocated block
};
@@ -700,8 +700,7 @@ private:
offs_t m_bytestart; // byte-adjusted start offset
offs_t m_byteend; // byte-adjusted end offset
int m_curentry; // current entry
- bank_entry * m_entry; // array of entries (dynamically allocated)
- int m_entry_count; // number of allocated entries
+ dynamic_array<bank_entry> m_entry; // array of entries (dynamically allocated)
astring m_name; // friendly name for this bank
astring m_tag; // tag for this bank
simple_list<bank_reference> m_reflist; // linked list of address spaces referencing this bank
diff --git a/src/emu/render.c b/src/emu/render.c
index f946179f08f..57b31a12a70 100644
--- a/src/emu/render.c
+++ b/src/emu/render.c
@@ -333,8 +333,6 @@ render_texture::render_texture()
m_next(NULL),
m_bitmap(NULL),
m_format(TEXFORMAT_ARGB32),
- m_bcglookup(NULL),
- m_bcglookup_entries(0),
m_osddata(~0L),
m_scaler(NULL),
m_param(NULL),
@@ -394,11 +392,6 @@ void render_texture::release()
m_sbounds.set(0, -1, 0, -1);
m_format = TEXFORMAT_ARGB32;
m_curseq = 0;
-
- // free any B/C/G lookup tables
- auto_free(m_manager->machine(), m_bcglookup);
- m_bcglookup = NULL;
- m_bcglookup_entries = 0;
}
@@ -565,14 +558,7 @@ const rgb_t *render_texture::get_adjusted_palette(render_container &container)
// otherwise, ensure we have memory allocated and compute the adjusted result ourself
numentries = m_bitmap->palette()->num_colors() * m_bitmap->palette()->num_groups();
- if (m_bcglookup == NULL || m_bcglookup_entries < numentries)
- {
- rgb_t *newlookup = auto_alloc_array(m_manager->machine(), rgb_t, numentries);
- memcpy(newlookup, m_bcglookup, m_bcglookup_entries * sizeof(rgb_t));
- auto_free(m_manager->machine(), m_bcglookup);
- m_bcglookup = newlookup;
- m_bcglookup_entries = numentries;
- }
+ m_bcglookup.resize(numentries);
for (int index = 0; index < numentries; index++)
{
UINT8 r = container.apply_brightness_contrast_gamma(adjusted[index].r());
diff --git a/src/emu/render.h b/src/emu/render.h
index 0b92b29199c..75bea195e95 100644
--- a/src/emu/render.h
+++ b/src/emu/render.h
@@ -454,8 +454,7 @@ private:
bitmap_t * m_bitmap; // pointer to the original bitmap
rectangle m_sbounds; // source bounds within the bitmap
texture_format m_format; // format of the texture data
- rgb_t * m_bcglookup; // dynamically allocated B/C/G lookup table
- UINT32 m_bcglookup_entries; // number of B/C/G lookup entries allocated
+ dynamic_array<rgb_t> m_bcglookup; // dynamically allocated B/C/G lookup table
UINT64 m_osddata; // aux data to pass to osd
// scaling state (ARGB32 only)
diff --git a/src/emu/rendfont.c b/src/emu/rendfont.c
index 6dbb46d050f..91f75008f7e 100644
--- a/src/emu/rendfont.c
+++ b/src/emu/rendfont.c
@@ -54,7 +54,10 @@ inline render_font::glyph &render_font::get_char(unicode_char chnum)
// grab the table; if none, return the dummy character
glyph *glyphtable = m_glyphs[chnum / 256];
if (glyphtable == NULL && m_format == FF_OSD)
- glyphtable = m_glyphs[chnum / 256] = auto_alloc_array_clear(m_manager.machine(), glyph, 256);
+ {
+ m_glyphs[chnum / 256].resize(256);
+ glyphtable = m_glyphs[chnum / 256];
+ }
if (glyphtable == NULL)
return dummy_glyph;
@@ -83,12 +86,9 @@ render_font::render_font(render_manager &manager, const char *filename)
m_height(0),
m_yoffs(0),
m_scale(1.0f),
- m_rawdata(NULL),
m_rawsize(0),
m_osdfont(NULL)
{
- memset(m_glyphs, 0, sizeof(m_glyphs));
-
// if this is an OSD font, we're done
if (filename != NULL)
{
@@ -133,9 +133,6 @@ render_font::~render_font()
glyph &gl = m_glyphs[tablenum][charnum];
m_manager.texture_free(gl.texture);
}
-
- // free the subtable itself
- auto_free(m_manager.machine(), m_glyphs[tablenum]);
}
// free the raw data and the size itself
@@ -380,15 +377,15 @@ bool render_font::load_cached_bdf(const char *filename)
// determine the file size and allocate memory
m_rawsize = file.size();
- char *data = auto_alloc_array_clear(m_manager.machine(), char, m_rawsize + 1);
+ m_rawdata.resize(m_rawsize + 1);
// read the first chunk
- UINT32 bytes = file.read(data, MIN(CACHED_BDF_HASH_SIZE, m_rawsize));
+ UINT32 bytes = file.read(m_rawdata, MIN(CACHED_BDF_HASH_SIZE, m_rawsize));
if (bytes != MIN(CACHED_BDF_HASH_SIZE, m_rawsize))
return false;
// has the chunk
- UINT32 hash = crc32(0, (const UINT8 *)data, bytes) ^ (UINT32)m_rawsize;
+ UINT32 hash = crc32(0, (const UINT8 *)&m_rawdata[0], bytes) ^ (UINT32)m_rawsize;
// create the cached filename, changing the 'F' to a 'C' on the extension
astring cachedname(filename);
@@ -406,7 +403,7 @@ bool render_font::load_cached_bdf(const char *filename)
// if that worked, we're done
if (result)
{
- auto_free(m_manager.machine(), data);
+ m_rawdata.reset();
return true;
}
}
@@ -415,17 +412,16 @@ bool render_font::load_cached_bdf(const char *filename)
// read in the rest of the font
if (bytes < m_rawsize)
{
- UINT32 read = file.read(data + bytes, m_rawsize - bytes);
+ UINT32 read = file.read(m_rawdata + bytes, m_rawsize - bytes);
if (read != m_rawsize - bytes)
{
- auto_free(m_manager.machine(), data);
+ m_rawdata.reset();
return false;
}
}
// NULL-terminate the data and attach it to the font
- data[m_rawsize] = 0;
- m_rawdata = data;
+ m_rawdata[m_rawsize] = 0;
// load the BDF
bool result = load_bdf();
@@ -519,8 +515,8 @@ bool render_font::load_bdf()
if (charnum >= 0 && charnum < 65536 && rawdata != NULL && bmwidth >= 0 && bmheight >= 0)
{
// if we don't have a subtable yet, make one
- if (m_glyphs[charnum / 256] == NULL)
- m_glyphs[charnum / 256] = auto_alloc_array_clear(m_manager.machine(), glyph, 256);
+ if (m_glyphs[charnum / 256].count() == 0)
+ m_glyphs[charnum / 256].resize(256);
// fill in the entry
glyph &gl = m_glyphs[charnum / 256][charnum % 256];
@@ -581,11 +577,11 @@ bool render_font::load_cached(emu_file &file, UINT32 hash)
return false;
// now read the rest of the data
- UINT8 *data = auto_alloc_array(m_manager.machine(), UINT8, filesize - CACHED_HEADER_SIZE);
- bytes_read = file.read(data, filesize - CACHED_HEADER_SIZE);
+ m_rawdata.resize(filesize - CACHED_HEADER_SIZE);
+ bytes_read = file.read(m_rawdata, filesize - CACHED_HEADER_SIZE);
if (bytes_read != filesize - CACHED_HEADER_SIZE)
{
- auto_free(m_manager.machine(), data);
+ m_rawdata.reset();
return false;
}
@@ -593,12 +589,12 @@ bool render_font::load_cached(emu_file &file, UINT32 hash)
UINT64 offset = numchars * CACHED_CHAR_SIZE;
for (int chindex = 0; chindex < numchars; chindex++)
{
- const UINT8 *info = &data[chindex * CACHED_CHAR_SIZE];
+ const UINT8 *info = reinterpret_cast<UINT8 *>(&m_rawdata[chindex * CACHED_CHAR_SIZE]);
int chnum = (info[0] << 8) | info[1];
// if we don't have a subtable yet, make one
- if (m_glyphs[chnum / 256] == NULL)
- m_glyphs[chnum / 256] = auto_alloc_array_clear(m_manager.machine(), glyph, 256);
+ if (m_glyphs[chnum / 256].count() == 0)
+ m_glyphs[chnum / 256].resize(256);
// fill in the entry
glyph &gl = m_glyphs[chnum / 256][chnum % 256];
@@ -607,20 +603,19 @@ bool render_font::load_cached(emu_file &file, UINT32 hash)
gl.yoffs = (INT16)((info[6] << 8) | info[7]);
gl.bmwidth = (info[8] << 8) | info[9];
gl.bmheight = (info[10] << 8) | info[11];
- gl.rawdata = (char *)data + offset;
+ gl.rawdata = (char *)m_rawdata + offset;
// advance the offset past the character
offset += (gl.bmwidth * gl.bmheight + 7) / 8;
if (offset > filesize - CACHED_HEADER_SIZE)
{
- auto_free(m_manager.machine(), data);
+ m_rawdata.reset();
return false;
}
}
// reuse the chartable as a temporary buffer
m_format = FF_CACHED;
- m_rawdata = (char *)data;
return true;
}
@@ -652,15 +647,13 @@ bool render_font::save_cached(const char *filename, UINT32 hash)
}
}
- UINT8 *chartable = NULL;
- UINT8 *tempbuffer = NULL;
try
{
// allocate an array to hold the character data
- chartable = auto_alloc_array_clear(m_manager.machine(), UINT8, numchars * CACHED_CHAR_SIZE);
+ dynamic_buffer chartable(numchars * CACHED_CHAR_SIZE, 0);
// allocate a temp buffer to compress into
- tempbuffer = auto_alloc_array(m_manager.machine(), UINT8, 65536);
+ dynamic_buffer tempbuffer(65536);
// write the header
UINT8 *dest = tempbuffer;
@@ -760,17 +753,11 @@ bool render_font::save_cached(const char *filename, UINT32 hash)
bytes_written = file.write(chartable, numchars * CACHED_CHAR_SIZE);
if (bytes_written != numchars * CACHED_CHAR_SIZE)
throw emu_fatalerror("Error writing cached file");
-
- // all done
- auto_free(m_manager.machine(), tempbuffer);
- auto_free(m_manager.machine(), chartable);
return true;
}
catch (...)
{
file.remove_on_close();
- auto_free(m_manager.machine(), tempbuffer);
- auto_free(m_manager.machine(), chartable);
return false;
}
}
diff --git a/src/emu/rendfont.h b/src/emu/rendfont.h
index bd6f840cf0c..31a0781bd59 100644
--- a/src/emu/rendfont.h
+++ b/src/emu/rendfont.h
@@ -50,12 +50,19 @@ private:
class glyph
{
public:
+ glyph()
+ : width(0),
+ xoffs(0), yoffs(0),
+ bmwidth(0), bmheight(0),
+ rawdata(NULL),
+ texture(NULL) { }
+
INT32 width; // width from this character to the next
INT32 xoffs, yoffs; // X and Y offset from baseline to top,left of bitmap
INT32 bmwidth, bmheight; // width and height of bitmap
const char * rawdata; // pointer to the raw data for this one
- bitmap_argb32 bitmap; // pointer to the bitmap containing the raw data
render_texture * texture; // pointer to a texture for rendering and sizing
+ bitmap_argb32 bitmap; // pointer to the bitmap containing the raw data
};
// internal format
@@ -81,8 +88,8 @@ private:
int m_height; // height of the font, from ascent to descent
int m_yoffs; // y offset from baseline to descent
float m_scale; // 1 / height precomputed
- glyph * m_glyphs[256]; // array of glyph subtables
- const char * m_rawdata; // pointer to the raw data for the font
+ dynamic_array<glyph> m_glyphs[256]; // array of glyph subtables
+ dynamic_array<char> m_rawdata; // pointer to the raw data for the font
UINT64 m_rawsize; // size of the raw font data
osd_font m_osdfont; // handle to the OSD font
diff --git a/src/emu/rendlay.c b/src/emu/rendlay.c
index b9fd375835c..17e8963669f 100644
--- a/src/emu/rendlay.c
+++ b/src/emu/rendlay.c
@@ -404,8 +404,7 @@ layout_element::layout_element(running_machine &machine, xml_data_node &elemnode
m_machine(machine),
m_complist(machine.respool()),
m_defstate(0),
- m_maxstate(0),
- m_elemtex(NULL)
+ m_maxstate(0)
{
// extract the name
const char *name = xml_get_attribute_string_with_subst(machine, elemnode, "name", NULL);
@@ -470,7 +469,7 @@ layout_element::layout_element(running_machine &machine, xml_data_node &elemnode
}
// allocate an array of element textures for the states
- m_elemtex = auto_alloc_array(machine, texture, m_maxstate + 1);
+ m_elemtex.resize(m_maxstate + 1);
}
@@ -480,8 +479,6 @@ layout_element::layout_element(running_machine &machine, xml_data_node &elemnode
layout_element::~layout_element()
{
- // loop over all states and free their textures
- auto_free(machine(), m_elemtex);
}
diff --git a/src/emu/rendlay.h b/src/emu/rendlay.h
index a0873c7da0d..dc46a171542 100644
--- a/src/emu/rendlay.h
+++ b/src/emu/rendlay.h
@@ -173,7 +173,7 @@ private:
simple_list<component> m_complist; // list of components
int m_defstate; // default state of this element
int m_maxstate; // maximum state value for all components
- texture * m_elemtex; // array of element textures used for managing the scaled bitmaps
+ dynamic_array<texture> m_elemtex; // array of element textures used for managing the scaled bitmaps
};
diff --git a/src/emu/romload.c b/src/emu/romload.c
index 0142420ee6b..38485b74b03 100644
--- a/src/emu/romload.c
+++ b/src/emu/romload.c
@@ -715,7 +715,6 @@ static int read_rom_data(romload_private *romdata, const rom_entry *parent_regio
int numgroups = (numbytes + groupsize - 1) / groupsize;
UINT8 *base = romdata->region->base() + ROM_GETOFFSET(romp);
UINT32 tempbufsize;
- UINT8 *tempbuf;
int i;
LOG(("Loading ROM data: offs=%X len=%X mask=%02X group=%d skip=%d reverse=%d\n", ROM_GETOFFSET(romp), numbytes, datamask, groupsize, skip, reversed));
@@ -738,7 +737,7 @@ static int read_rom_data(romload_private *romdata, const rom_entry *parent_regio
/* use a temporary buffer for complex loads */
tempbufsize = MIN(TEMPBUFFER_MAX_SIZE, numbytes);
- tempbuf = auto_alloc_array(romdata->machine(), UINT8, tempbufsize);
+ dynamic_buffer tempbuf(tempbufsize);
/* chunky reads for complex loads */
skip += groupsize;
@@ -813,7 +812,6 @@ static int read_rom_data(romload_private *romdata, const rom_entry *parent_regio
}
}
}
- auto_free(romdata->machine(), tempbuf);
LOG((" All done\n"));
return ROM_GETLENGTH(romp);
diff --git a/src/emu/sound.c b/src/emu/sound.c
index 0124f36f1d4..4d846ac9e35 100644
--- a/src/emu/sound.c
+++ b/src/emu/sound.c
@@ -500,16 +500,11 @@ void sound_stream::allocate_resample_buffers()
if (m_resample_bufalloc < bufsize)
{
// this becomes the new allocation size
- int oldsize = m_resample_bufalloc;
m_resample_bufalloc = bufsize;
// iterate over outputs and realloc their buffers
for (int inputnum = 0; inputnum < m_input.count(); inputnum++)
- {
- stream_input &input = m_input[inputnum];
- input.m_resample.resize(m_resample_bufalloc, true);
- memset(&input.m_resample[oldsize], 0, (m_resample_bufalloc - oldsize) * sizeof(stream_sample_t));
- }
+ m_input[inputnum].m_resample.resize_keep_and_clear_new(m_resample_bufalloc);
}
}
@@ -526,16 +521,11 @@ void sound_stream::allocate_output_buffers()
if (m_output_bufalloc < bufsize)
{
// this becomes the new allocation size
- int oldsize = m_output_bufalloc;
m_output_bufalloc = bufsize;
// iterate over outputs and realloc their buffers
for (int outputnum = 0; outputnum < m_output.count(); outputnum++)
- {
- stream_output &output = m_output[outputnum];
- output.m_buffer.resize(m_output_bufalloc, true);
- memset(&output.m_buffer[oldsize], 0, (m_output_bufalloc - oldsize) * sizeof(stream_sample_t));
- }
+ m_output[outputnum].m_buffer.resize_keep_and_clear_new(m_output_bufalloc);
}
}
diff --git a/src/lib/util/coretmpl.h b/src/lib/util/coretmpl.h
index db8442c0e8d..9c385f8c84a 100644
--- a/src/lib/util/coretmpl.h
+++ b/src/lib/util/coretmpl.h
@@ -17,6 +17,9 @@
#include "osdcore.h"
+#undef assert
+#define assert(x) do { if (!(x)) { printf("Assert: %s\n", #x); asm("int $3"); } } while (0)
+
// ======================> dynamic_array
// an array that is dynamically sized and can optionally auto-expand
@@ -30,10 +33,10 @@ private:
public:
// construction/destruction
- dynamic_array(int initial = 0, bool clearit = false)
+ dynamic_array(int initial = 0, int clearvalue = -1)
: m_array(NULL),
m_count(0),
- m_allocated(0) { if (initial != 0) expand_internal(initial); m_count = initial; if (clearit) clear(); }
+ m_allocated(0) { if (initial != 0) expand_internal(initial); m_count = initial; if (clearvalue != -1) clear(clearvalue); }
virtual ~dynamic_array() { reset(); }
// operators
@@ -45,31 +48,43 @@ public:
// simple getters
int count() const { return m_count; }
- // helpers
- const _ElementType &append(const _ElementType &element) { if (m_count == m_allocated) expand_internal((m_allocated == 0) ? 16 : (m_allocated << 1), true); m_array[m_count++] = element; return element; }
+ // core operations
+ const _ElementType &append(const _ElementType &element) { if (m_count == m_allocated) expand_and_keep_internal((m_allocated == 0) ? 16 : (m_allocated << 1)); m_array[m_count++] = element; return element; }
void reset() { delete[] m_array; m_array = NULL; m_count = m_allocated = 0; }
- void resize(int count, bool keepdata = false) { if (count > m_allocated) expand_internal(count, keepdata); m_count = count; }
-#ifdef __GNUC__
- void clear() { assert(__is_pod(_ElementType)); memset(m_array, 0, m_count * sizeof(*m_array)); }
-#else
- void clear() { memset(m_array, 0, m_count * sizeof(*m_array)); }
-#endif
- void resize_and_clear(int count) { resize(count); clear(); }
+ void resize(int count) { if (count > m_allocated) expand_internal(count); m_count = count; }
+ void resize_keep(int count) { if (count > m_allocated) expand_and_keep_internal(count); m_count = count; }
+ void clear(UINT8 data = 0) { clear_internal(0, m_count, data); }
+
+ // compound operations
+ void resize_and_clear(int count, UINT8 data = 0) { resize(count); clear(data); }
+ void resize_keep_and_clear_new(int count, UINT8 data = 0) { int oldcount = m_count; resize_keep(count); if (oldcount < m_count) clear_internal(oldcount, m_count - oldcount, data); }
private:
// internal helpers
- void expand_internal(int count, bool keepdata = true)
+ void expand_internal(int count)
{
- // allocate a new array, copy the old one, and proceed
- m_allocated = count;
- _ElementType *newarray = new _ElementType[m_allocated];
- if (keepdata)
- for (int index = 0; index < m_count; index++)
- newarray[index] = m_array[index];
delete[] m_array;
- m_array = newarray;
+ m_array = new _ElementType[count];
+ m_allocated = count;
}
+ void expand_and_keep_internal(int count)
+ {
+ _ElementType *oldarray = m_array;
+ int oldcount = m_count;
+ m_array = new _ElementType[count];
+ m_allocated = count;
+ for (int index = 0; index < oldcount; index++)
+ m_array[index] = oldarray[index];
+ delete[] oldarray;
+ }
+
+#ifdef __GNUC__
+ void clear_internal(UINT32 start, UINT32 count, UINT8 data) { assert(__is_pod(_ElementType)); memset(&m_array[start], data, count * sizeof(*m_array)); }
+#else
+ void clear_internal(UINT32 start, UINT32 count, UINT8 data) { memset(&m_array[start], data, count * sizeof(*m_array)); }
+#endif
+
// internal state
_ElementType * m_array; // allocated array
int m_count; // number of objects accessed in the list
diff --git a/src/mame/includes/stv.h b/src/mame/includes/stv.h
index 74fa8e23ccb..e4bc21eb0b9 100644
--- a/src/mame/includes/stv.h
+++ b/src/mame/includes/stv.h
@@ -633,7 +633,7 @@ public:
int get_timing_command( void );
direntryT curroot; // root entry of current filesystem
- direntryT *curdir; // current directory
+ dynamic_array<direntryT> curdir; // current directory
int numfiles; // # of entries in current directory
int firstfile; // first non-directory file