Add table initializing alloc to slab allocator.

This commit is contained in:
Bartosz Taudul 2019-09-29 20:18:16 +02:00
parent 59632f0d37
commit 781ebeb835

View File

@ -58,6 +58,26 @@ public:
return (T*)ret;
}
template<typename T>
T* AllocInit( size_t sz )
{
const auto size = sizeof( T ) * sz;
assert( size <= BlockSize );
if( m_offset + size > BlockSize )
{
DoAlloc();
}
void* ret = m_ptr + m_offset;
T* ptr = (T*)ret;
for( size_t i=0; i<sz; i++ )
{
new( ptr ) T;
ptr++;
}
m_offset += size;
return (T*)ret;
}
template<typename T>
tracy_force_inline T* Alloc()
{