Add LocationToString() helper.

This commit is contained in:
Bartosz Taudul 2021-06-19 12:33:23 +02:00
parent c69cf5bd3f
commit 91f1845d92
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3
2 changed files with 15 additions and 0 deletions

View File

@ -411,6 +411,20 @@ const char* MemSizeToString( int64_t val )
return buf;
}
const char* LocationToString( const char* fn, uint32_t line )
{
if( line == 0 ) return fn;
enum { Pool = 8 };
static char bufpool[Pool][4096];
static int bufsel = 0;
char* buf = bufpool[bufsel];
bufsel = ( bufsel + 1 ) % Pool;
sprintf( buf, "%s:%i", fn, line );
return buf;
}
namespace detail
{

View File

@ -126,6 +126,7 @@ static inline const char* RealToString( double val )
const char* TimeToString( int64_t ns );
const char* TimeToStringExact( int64_t ns );
const char* MemSizeToString( int64_t val );
const char* LocationToString( const char* fn, uint32_t line );
}