Allow changing lz4 size type.

This commit is contained in:
Bartosz Taudul 2017-09-13 22:58:04 +02:00
parent 16dd561029
commit efd66bb609
2 changed files with 7 additions and 5 deletions

View File

@ -120,10 +120,10 @@ void Profiler::Worker()
#ifdef _DEBUG #ifdef _DEBUG
if( sock->Send( buf, ptr - buf ) == -1 ) break; if( sock->Send( buf, ptr - buf ) == -1 ) break;
#else #else
char lz4[LZ4Size + sizeof( uint16_t )]; char lz4[LZ4Size + sizeof( lz4sz_t )];
const uint16_t lz4sz = LZ4_compress_default( buf, lz4+2, ptr - buf, LZ4Size ); const lz4sz_t lz4sz = LZ4_compress_default( buf, lz4 + sizeof( lz4sz_t ), ptr - buf, LZ4Size );
memcpy( lz4, &lz4sz, sizeof( uint16_t ) ); memcpy( lz4, &lz4sz, sizeof( lz4sz ) );
if( sock->Send( lz4, lz4sz ) == -1 ) break; if( sock->Send( lz4, lz4sz + sizeof( lz4sz_t ) ) == -1 ) break;
#endif #endif
} }
else else

View File

@ -9,9 +9,11 @@
namespace tracy namespace tracy
{ {
using lz4sz_t = uint16_t;
enum { TargetFrameSize = 64000 }; enum { TargetFrameSize = 64000 };
enum { LZ4Size = LZ4_COMPRESSBOUND( TargetFrameSize ) }; enum { LZ4Size = LZ4_COMPRESSBOUND( TargetFrameSize ) };
static_assert( LZ4Size <= std::numeric_limits<uint16_t>::max(), "LZ4Size greater than uint16_t" ); static_assert( LZ4Size <= std::numeric_limits<lz4sz_t>::max(), "LZ4Size greater than lz4sz_t" );
} }