diff --git a/src/emu/emupal.c b/src/emu/emupal.c index 4b338f3e629..d05220e9b5d 100644 --- a/src/emu/emupal.c +++ b/src/emu/emupal.c @@ -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) diff --git a/src/emu/machine/laserdsc.c b/src/emu/machine/laserdsc.c index 8e5261da957..dfc3c066515 100644 --- a/src/emu/machine/laserdsc.c +++ b/src/emu/machine/laserdsc.c @@ -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++) diff --git a/src/lib/util/palette.c b/src/lib/util/palette.c index 719a832c088..a912b7f5672 100644 --- a/src/lib/util/palette.c +++ b/src/lib/util/palette.c @@ -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 //------------------------------------------------- diff --git a/src/lib/util/palette.h b/src/lib/util/palette.h index 06370118d05..db29477a8e7 100644 --- a/src/lib/util/palette.h +++ b/src/lib/util/palette.h @@ -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