mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-25 23:44:35 +00:00
Add basic error handling
This commit is contained in:
parent
55da9d1084
commit
f28e45f2f6
@ -193,7 +193,8 @@ ini_t* ini_load(const char *filename) {
|
||||
|
||||
/* Get file size */
|
||||
fseek(fp, 0, SEEK_END);
|
||||
sz = ftell(fp);
|
||||
const long file_size = ftell(fp);
|
||||
sz = file_size > 0 ? file_size : 0;
|
||||
rewind(fp);
|
||||
|
||||
/* Load file content into memory, null terminate, init end var */
|
||||
|
@ -85,7 +85,8 @@ static inline char* PrintFloat( char* begin, char* end, T value, int precision )
|
||||
#ifndef NO_CHARCONV
|
||||
return std::to_chars( begin, end, value, std::chars_format::fixed, precision ).ptr;
|
||||
#else
|
||||
return begin + sprintf( begin, "%.*f", precision, value );
|
||||
auto length = sprintf( begin, "%.*f", precision, value );
|
||||
return length < 0 ? "" : begin + length; // TODO: Proper error handling for negative length
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -95,7 +96,8 @@ static inline char* PrintFloat( char* begin, char* end, T value )
|
||||
#ifndef NO_CHARCONV
|
||||
return std::to_chars( begin, end, value, std::chars_format::fixed ).ptr;
|
||||
#else
|
||||
return begin + sprintf( begin, "%f", value );
|
||||
auto length = sprintf( begin, "%f", value );
|
||||
return length < 0 ? "" : begin + length; // TODO: Proper error handling for negative length
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user