mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-23 06:44:35 +00:00
Replace getline().
This commit is contained in:
parent
7f10265e34
commit
efae847690
@ -1485,21 +1485,25 @@ void SysTraceGetExternalName( uint64_t thread, const char*& threadName, const ch
|
|||||||
f = fopen( fn, "rb" );
|
f = fopen( fn, "rb" );
|
||||||
if( f )
|
if( f )
|
||||||
{
|
{
|
||||||
|
char* tmp = (char*)tracy_malloc_fast( 8*1024 );
|
||||||
|
const auto fsz = (ptrdiff_t)fread( tmp, 1, 8*1024, f );
|
||||||
|
fclose( f );
|
||||||
|
|
||||||
int pid = -1;
|
int pid = -1;
|
||||||
size_t lsz = 1024;
|
auto line = tmp;
|
||||||
auto line = (char*)tracy_malloc_fast( lsz );
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
auto rd = getline( &line, &lsz, f );
|
|
||||||
if( rd <= 0 ) break;
|
|
||||||
if( memcmp( "Tgid:\t", line, 6 ) == 0 )
|
if( memcmp( "Tgid:\t", line, 6 ) == 0 )
|
||||||
{
|
{
|
||||||
pid = atoi( line + 6 );
|
pid = atoi( line + 6 );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
while( line - tmp < fsz && *line != '\n' ) line++;
|
||||||
|
if( *line != '\n' ) break;
|
||||||
|
line++;
|
||||||
}
|
}
|
||||||
tracy_free_fast( line );
|
tracy_free_fast( tmp );
|
||||||
fclose( f );
|
|
||||||
if( pid >= 0 )
|
if( pid >= 0 )
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user