added option to clear with value for arrays (nw)

This commit is contained in:
Miodrag Milanovic 2015-12-17 17:36:00 +01:00
parent c0740a42c8
commit a111c124c7
2 changed files with 11 additions and 1 deletions

View File

@ -37,6 +37,16 @@ inline std::unique_ptr<T> make_unique_clear(std::size_t size)
return ptr;
}
template<typename T,unsigned char F>
inline std::unique_ptr<T> make_unique_clear(std::size_t size)
{
auto ptr = std::make_unique<T>(size);
static_assert(std::is_array<T>::value, "Type must be array");
memset(ptr.get(), F, sizeof(std::remove_extent<T>) * size);
return ptr;
}
template<typename T>
inline std::unique_ptr<T> make_unique_clear()
{

View File

@ -245,7 +245,7 @@ void segas32_state::common_start(int multi32)
/* allocate pre-rendered solid lines of 0's and ffff's */
m_solid_0000 = make_unique_clear<UINT16[]>(512);
m_solid_ffff = make_unique_clear<UINT16[]>(512);
m_solid_ffff = make_unique_clear<UINT16[],0xff>(512);
memset(m_system32_videoram, 0x00, 0x20000);