From 91f1845d92e163739c149297f6d64d44ab1d20c6 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 19 Jun 2021 12:33:23 +0200 Subject: [PATCH] Add LocationToString() helper. --- server/TracyPrint.cpp | 14 ++++++++++++++ server/TracyPrint.hpp | 1 + 2 files changed, 15 insertions(+) diff --git a/server/TracyPrint.cpp b/server/TracyPrint.cpp index 632f3afb..1aa4bcd2 100644 --- a/server/TracyPrint.cpp +++ b/server/TracyPrint.cpp @@ -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 { diff --git a/server/TracyPrint.hpp b/server/TracyPrint.hpp index 2a03b6ed..edff5627 100644 --- a/server/TracyPrint.hpp +++ b/server/TracyPrint.hpp @@ -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 ); }