mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-27 08:14:34 +00:00
Fix shortening of negative memory values.
This commit is contained in:
parent
4a12e14a1b
commit
92c1685528
@ -182,7 +182,9 @@ static const char* MemSizeToString( int64_t val )
|
|||||||
char* buf = bufpool[bufsel];
|
char* buf = bufpool[bufsel];
|
||||||
bufsel = ( bufsel + 1 ) % Pool;
|
bufsel = ( bufsel + 1 ) % Pool;
|
||||||
|
|
||||||
if( val < 10000ll )
|
const auto aval = abs( val );
|
||||||
|
|
||||||
|
if( aval < 10000ll )
|
||||||
{
|
{
|
||||||
sprintf( buf, "%" PRIi64 " bytes", val );
|
sprintf( buf, "%" PRIi64 " bytes", val );
|
||||||
return buf;
|
return buf;
|
||||||
@ -197,17 +199,17 @@ static const char* MemSizeToString( int64_t val )
|
|||||||
};
|
};
|
||||||
Unit unit;
|
Unit unit;
|
||||||
|
|
||||||
if( val < 10000ll * 1024 )
|
if( aval < 10000ll * 1024 )
|
||||||
{
|
{
|
||||||
sprintf( buf, "%.2f", val / 1024. );
|
sprintf( buf, "%.2f", val / 1024. );
|
||||||
unit = Unit::Kilobyte;
|
unit = Unit::Kilobyte;
|
||||||
}
|
}
|
||||||
else if( val < 10000ll * 1024 * 1024 )
|
else if( aval < 10000ll * 1024 * 1024 )
|
||||||
{
|
{
|
||||||
sprintf( buf, "%.2f", val / ( 1024. * 1024 ) );
|
sprintf( buf, "%.2f", val / ( 1024. * 1024 ) );
|
||||||
unit = Unit::Megabyte;
|
unit = Unit::Megabyte;
|
||||||
}
|
}
|
||||||
else if( val < 10000ll * 1024 * 1024 * 1024 )
|
else if( aval < 10000ll * 1024 * 1024 * 1024 )
|
||||||
{
|
{
|
||||||
sprintf( buf, "%.2f", val / ( 1024. * 1024 * 1024 ) );
|
sprintf( buf, "%.2f", val / ( 1024. * 1024 * 1024 ) );
|
||||||
unit = Unit::Gigabyte;
|
unit = Unit::Gigabyte;
|
||||||
|
Loading…
Reference in New Issue
Block a user