Change palette_t allocation so that it uses matching new/delete operators.

This commit is contained in:
Aaron Giles 2014-02-18 17:41:16 +00:00
parent d048dae125
commit 64d9280eb6
4 changed files with 16 additions and 5 deletions

View File

@ -593,7 +593,7 @@ static void allocate_palette(running_machine &machine, palette_private *palette)
assert_always(machine.total_colors() * numgroups <= 65536, "Error: palette has more than 65536 colors.");
/* allocate a palette object containing all the colors and groups */
machine.palette = new palette_t(machine.total_colors(), numgroups);
machine.palette = palette_t::alloc(machine.total_colors(), numgroups);
/* configure the groups */
if (palette->shadow_group != 0)

View File

@ -769,7 +769,7 @@ void laserdisc_device::init_video()
m_screen->register_vblank_callback(vblank_state_delegate(FUNC(laserdisc_device::vblank_state_changed), this));
// allocate palette for applying brightness/contrast/gamma
m_videopalette = new palette_t(256);
m_videopalette = palette_t::alloc(256);
if (m_videopalette == NULL)
throw emu_fatalerror("Out of memory allocating video palette");
for (int index = 0; index < 256; index++)

View File

@ -188,6 +188,16 @@ const UINT32 *palette_client::dirty_list(UINT32 &mindirty, UINT32 &maxdirty)
// PALETTE_T
//**************************************************************************
//-------------------------------------------------
// alloc - static allocator
//-------------------------------------------------
palette_t *palette_t::alloc(UINT32 numcolors, UINT32 numgroups)
{
return new palette_t(numcolors, numgroups);
}
//-------------------------------------------------
// palette_t - constructor
//-------------------------------------------------

View File

@ -106,8 +106,8 @@ class palette_t
friend class palette_client;
public:
// construction/destruction
palette_t(UINT32 numcolors, UINT32 numgroups = 1);
// static constructor: used to ensure same new/delete is used
static palette_t *alloc(UINT32 numcolors, UINT32 numgroups = 1);
// reference counting
void ref() { m_refcount++; }
@ -147,7 +147,8 @@ public:
void normalize_range(UINT32 start, UINT32 end, int lum_min = 0, int lum_max = 255);
private:
// destructor -- can only destruct via
// construction/destruction
palette_t(UINT32 numcolors, UINT32 numgroups = 1);
~palette_t();
// internal helpers