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
if( sock->Send( buf, ptr - buf ) == -1 ) break;
#else
char lz4[LZ4Size + sizeof( uint16_t )];
const uint16_t lz4sz = LZ4_compress_default( buf, lz4+2, ptr - buf, LZ4Size );
memcpy( lz4, &lz4sz, sizeof( uint16_t ) );
if( sock->Send( lz4, lz4sz ) == -1 ) break;
char lz4[LZ4Size + sizeof( lz4sz_t )];
const lz4sz_t lz4sz = LZ4_compress_default( buf, lz4 + sizeof( lz4sz_t ), ptr - buf, LZ4Size );
memcpy( lz4, &lz4sz, sizeof( lz4sz ) );
if( sock->Send( lz4, lz4sz + sizeof( lz4sz_t ) ) == -1 ) break;
#endif
}
else

View File

@ -9,9 +9,11 @@
namespace tracy
{
using lz4sz_t = uint16_t;
enum { TargetFrameSize = 64000 };
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" );
}