Remove MAX_FMT_TRIES. I don't know why it was there.
This commit is contained in:
@@ -252,7 +252,6 @@ RString ssprintf( const char *fmt, ...)
|
|||||||
return vssprintf(fmt, va);
|
return vssprintf(fmt, va);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MAX_FMT_TRIES 5 // #of times we try
|
|
||||||
#define FMT_BLOCK_SIZE 2048 // # of bytes to increment per try
|
#define FMT_BLOCK_SIZE 2048 // # of bytes to increment per try
|
||||||
|
|
||||||
RString vssprintf( const char *szFormat, va_list argList )
|
RString vssprintf( const char *szFormat, va_list argList )
|
||||||
@@ -271,12 +270,11 @@ RString vssprintf( const char *szFormat, va_list argList )
|
|||||||
iChars += iTry * FMT_BLOCK_SIZE;
|
iChars += iTry * FMT_BLOCK_SIZE;
|
||||||
pBuf = (char*) _alloca( sizeof(char)*iChars );
|
pBuf = (char*) _alloca( sizeof(char)*iChars );
|
||||||
iUsed = vsnprintf( pBuf, iChars-1, szFormat, argList );
|
iUsed = vsnprintf( pBuf, iChars-1, szFormat, argList );
|
||||||
} while ( iUsed < 0 && iTry++ < MAX_FMT_TRIES );
|
++iTry;
|
||||||
|
} while( iUsed < 0 );
|
||||||
int iActual = min( iUsed, iChars-1 );
|
|
||||||
|
|
||||||
// assign whatever we managed to format
|
// assign whatever we managed to format
|
||||||
sStr.assign( pBuf, iActual );
|
sStr.assign( pBuf, iUsed );
|
||||||
#else
|
#else
|
||||||
static bool bExactSizeSupported;
|
static bool bExactSizeSupported;
|
||||||
static bool bInitialized = false;
|
static bool bInitialized = false;
|
||||||
@@ -306,7 +304,7 @@ RString vssprintf( const char *szFormat, va_list argList )
|
|||||||
|
|
||||||
int iChars = FMT_BLOCK_SIZE;
|
int iChars = FMT_BLOCK_SIZE;
|
||||||
int iTry = 1;
|
int iTry = 1;
|
||||||
do
|
while( 1 )
|
||||||
{
|
{
|
||||||
// Grow more than linearly (e.g. 512, 1536, 3072, etc)
|
// Grow more than linearly (e.g. 512, 1536, 3072, etc)
|
||||||
char *buf = GetBuffer(iChars);
|
char *buf = GetBuffer(iChars);
|
||||||
@@ -316,13 +314,14 @@ RString vssprintf( const char *szFormat, va_list argList )
|
|||||||
{
|
{
|
||||||
iChars += ((iTry+1) * FMT_BLOCK_SIZE);
|
iChars += ((iTry+1) * FMT_BLOCK_SIZE);
|
||||||
ReleaseBuffer();
|
ReleaseBuffer();
|
||||||
|
++iTry;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* OK */
|
/* OK */
|
||||||
sStr.ReleaseBuffer(iUsed);
|
sStr.ReleaseBuffer(iUsed);
|
||||||
break;
|
break;
|
||||||
} while ( iTry++ < MAX_FMT_TRIES );
|
}
|
||||||
#endif
|
#endif
|
||||||
return sStr;
|
return sStr;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user