1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-08 00:37:15 +01:00

Implemented a minimal version of ToStringF with a static buffer.

This commit is contained in:
Sandu Liviu Catalin 2015-11-11 08:54:50 +02:00
parent 68ac878fe9
commit 73b93d707c
2 changed files with 26 additions and 0 deletions

View File

@ -332,6 +332,27 @@ void DbgFtl(const char * type, const char * func, const char * fmt, ...)
va_end(args);
}
// ------------------------------------------------------------------------------------------------
const SQChar * ToStrF(const char * fmt, ...)
{
static char buf[128];
// Variable arguments structure
va_list args;
// Get the specified arguments
va_start (args, fmt);
// Run the specified format
int ret = std::vsnprintf(buf, sizeof(buf), fmt, args);
// Check for formatting errors
if (ret < 0)
{
LogErr("Failed to run the specified string format");
// Return an empty string
buf[0] = 0;
}
// Return the buffer
return buf;
}
// ------------------------------------------------------------------------------------------------
const SQChar * ToStringF(const char * fmt, ...)
{

View File

@ -109,6 +109,11 @@ void DbgWrn(const char * type, const char * func, const char * fmt, ...);
void DbgErr(const char * type, const char * func, const char * fmt, ...);
void DbgFtl(const char * type, const char * func, const char * fmt, ...);
/* ------------------------------------------------------------------------------------------------
* ...
*/
const SQChar * ToStrF(const char * fmt, ...);
/* ------------------------------------------------------------------------------------------------
* ...
*/