mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Don't waste bytes when we are already aligned
This commit is contained in:
parent
05fdd021c7
commit
b3b90796dc
|
@ -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;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue