mirror of
https://github.com/holub/mame
synced 2025-06-06 21:03:47 +03:00
palette.cpp: Use std::fill instead of memset for dirty vector; add range check
This commit is contained in:
parent
1944eded0d
commit
78f93a270c
@ -77,7 +77,7 @@ void palette_client::dirty_state::resize(uint32_t colors)
|
|||||||
// resize to the correct number of dwords and mark all entries dirty
|
// resize to the correct number of dwords and mark all entries dirty
|
||||||
uint32_t dirty_dwords = (colors + 31) / 32;
|
uint32_t dirty_dwords = (colors + 31) / 32;
|
||||||
m_dirty.resize(dirty_dwords);
|
m_dirty.resize(dirty_dwords);
|
||||||
memset(&m_dirty[0], 0xff, dirty_dwords*4);
|
std::fill(m_dirty.begin(), m_dirty.end(), ~uint32_t(0));
|
||||||
|
|
||||||
// mark all entries dirty
|
// mark all entries dirty
|
||||||
m_dirty[dirty_dwords - 1] &= (1 << (colors % 32)) - 1;
|
m_dirty[dirty_dwords - 1] &= (1 << (colors % 32)) - 1;
|
||||||
@ -108,7 +108,8 @@ void palette_client::dirty_state::mark_dirty(uint32_t index)
|
|||||||
void palette_client::dirty_state::reset()
|
void palette_client::dirty_state::reset()
|
||||||
{
|
{
|
||||||
// erase relevant entries in the new live one
|
// erase relevant entries in the new live one
|
||||||
memset(&m_dirty[m_mindirty / 32], 0, ((m_maxdirty / 32) + 1 - (m_mindirty / 32)) * sizeof(uint32_t));
|
if (m_mindirty <= m_maxdirty)
|
||||||
|
std::fill(&m_dirty[m_mindirty / 32], &m_dirty[(m_maxdirty / 32) + 1], 0);
|
||||||
m_mindirty = m_dirty.size() * 32 - 1;
|
m_mindirty = m_dirty.size() * 32 - 1;
|
||||||
m_maxdirty = 0;
|
m_maxdirty = 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user