From 07cb693cbb7604906c3c8ba973d2c465cc731387 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 21 Oct 2017 12:54:12 +0200 Subject: [PATCH] Separate slab init/noinit allocation functions. --- server/TracySlab.hpp | 10 ++++++++-- server/TracyView.cpp | 6 +++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/server/TracySlab.hpp b/server/TracySlab.hpp index e4f53815..cb85b663 100644 --- a/server/TracySlab.hpp +++ b/server/TracySlab.hpp @@ -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 + T* AllocInit() + { + return new( AllocRaw( sizeof( T ) ) ) T; + } + template T* Alloc() { - return new( Alloc( sizeof( T ) ) ) T; + return (T*)AllocRaw( sizeof( T ) ); } void Unalloc( size_t size ) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 7509b9c3..111c0589 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -568,7 +568,7 @@ void View::Process( const QueueItem& ev ) void View::ProcessZoneBegin( const QueueZoneBegin& ev ) { - auto zone = m_slab.Alloc(); + auto zone = m_slab.AllocInit(); 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(); + plot = m_slab.AllocInit(); plot->name = ev.name; plot->enabled = true; m_pendingPlots.emplace( ev.name, plot ); @@ -3052,7 +3052,7 @@ void View::ReadTimeline( FileRead& f, Vector& vec, Event* parent, const for( uint64_t i=0; i(); + auto zone = m_slab.AllocInit(); m_zonesCnt++; vec.push_back( zone );