From 2131eed4e72e1e429414575ab7fb185a1f39bd2d Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 9 Nov 2019 00:25:12 +0100 Subject: [PATCH] Support multiple types in Read2(). --- server/TracyFileRead.hpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/server/TracyFileRead.hpp b/server/TracyFileRead.hpp index 1e55a348..80918cc1 100644 --- a/server/TracyFileRead.hpp +++ b/server/TracyFileRead.hpp @@ -77,21 +77,21 @@ public: } - template - tracy_force_inline void Read2( T& v0, T& v1 ) + template + tracy_force_inline void Read2( T& v0, U& v1 ) { - if( sizeof( T ) * 2 < BufSize - m_offset ) + if( sizeof( T ) + sizeof( U ) < BufSize - m_offset ) { memcpy( &v0, m_buf + m_offset, sizeof( T ) ); - memcpy( &v1, m_buf + m_offset + sizeof( T ), sizeof( T ) ); - m_offset += sizeof( T ) * 2; + memcpy( &v1, m_buf + m_offset + sizeof( T ), sizeof( U ) ); + m_offset += sizeof( T ) + sizeof( U ); } else { - T tmp[2]; - ReadBig( tmp, sizeof( T ) * 2 ); + char tmp[sizeof( T ) + sizeof( U )]; + ReadBig( tmp, sizeof( T ) + sizeof( U ) ); memcpy( &v0, tmp, sizeof( T ) ); - memcpy( &v1, tmp+1, sizeof( T ) ); + memcpy( &v1, tmp + sizeof( T ), sizeof( U ) ); } }