Separate slab init/noinit allocation functions.

This commit is contained in:
Bartosz Taudul 2017-10-21 12:54:12 +02:00
parent ad338a7cfd
commit 07cb693cbb
2 changed files with 11 additions and 5 deletions

View File

@ -30,7 +30,7 @@ public:
}
}
void* Alloc( size_t size )
void* AllocRaw( size_t size )
{
assert( size <= BlockSize );
if( m_offset + size > BlockSize )
@ -45,10 +45,16 @@ public:
return ret;
}
template<typename T>
T* AllocInit()
{
return new( AllocRaw( sizeof( T ) ) ) T;
}
template<typename T>
T* Alloc()
{
return new( Alloc( sizeof( T ) ) ) T;
return (T*)AllocRaw( sizeof( T ) );
}
void Unalloc( size_t size )

View File

@ -568,7 +568,7 @@ void View::Process( const QueueItem& ev )
void View::ProcessZoneBegin( const QueueZoneBegin& ev )
{
auto zone = m_slab.Alloc<Event>();
auto zone = m_slab.AllocInit<Event>();
CheckSourceLocation( ev.srcloc );
@ -713,7 +713,7 @@ void View::ProcessPlotData( const QueuePlotData& ev )
auto pit = m_pendingPlots.find( ev.name );
if( pit == m_pendingPlots.end() )
{
plot = m_slab.Alloc<PlotData>();
plot = m_slab.AllocInit<PlotData>();
plot->name = ev.name;
plot->enabled = true;
m_pendingPlots.emplace( ev.name, plot );
@ -3052,7 +3052,7 @@ void View::ReadTimeline( FileRead& f, Vector<Event*>& vec, Event* parent, const
for( uint64_t i=0; i<sz; i++ )
{
auto zone = m_slab.Alloc<Event>();
auto zone = m_slab.AllocInit<Event>();
m_zonesCnt++;
vec.push_back( zone );