Don't waste bytes when we are already aligned

This commit is contained in:
Learath2 2020-10-13 17:30:30 +02:00
parent 05fdd021c7
commit b3b90796dc

View file

@ -41,7 +41,10 @@ class CCommandBuffer
void *Alloc(unsigned Requested, unsigned Alignment = alignof(std::max_align_t)) void *Alloc(unsigned Requested, unsigned Alignment = alignof(std::max_align_t))
{ {
size_t Offset = Alignment - (reinterpret_cast<uintptr_t>(m_pData + m_Used) % Alignment); size_t Offset = reinterpret_cast<uintptr_t>(m_pData + m_Used) % Alignment;
if(Offset)
Offset = Alignment - Offset;
if(Requested + Offset + m_Used > m_Size) if(Requested + Offset + m_Used > m_Size)
return 0; return 0;