Remove the need for the RString buffer.

For most areas, the call to `c_str()` is plenty.

For `RageUtil`, it's just a matter of new and delete.
This commit is contained in:
Jason Felds
2015-09-16 22:29:53 -04:00
parent b87af92a6b
commit cf545a3c01
3 changed files with 23 additions and 24 deletions
+1 -1
View File
@@ -206,7 +206,7 @@ void FileTransfer::StartTransfer( TransferType type, const RString &sURL, const
m_wSocket.SendData( sHeader.c_str(), sHeader.length() );
m_wSocket.SendData( "\r\n" );
m_wSocket.SendData( sRequestPayload.GetBuffer(), sRequestPayload.size() );
m_wSocket.SendData( sRequestPayload.c_str(), sRequestPayload.size() );
m_sStatus = "Header Sent.";
m_wSocket.blocking = false;
+5 -5
View File
@@ -454,11 +454,11 @@ RString ReadString( RageFileBasic &f, int iSize, RString &sError )
if( sError.size() != 0 )
return RString();
RString sBuf;
char *pBuf = sBuf.GetBuffer( iSize );
FileReading::ReadBytes( f, pBuf, iSize, sError );
sBuf.ReleaseBuffer( iSize );
return sBuf;
char *buf = new char[iSize];
FileReading::ReadBytes( f, buf, iSize, sError );
RString ret(buf);
delete [] buf;
return ret;
}
#define FATAL_ERROR(s) \
+17 -18
View File
@@ -468,30 +468,30 @@ RString vssprintf( const char *szFormat, va_list argList )
int iNeeded = vsnprintf( &ignore, 0, szFormat, tmp );
va_end(tmp);
char *buf = sStr.GetBuffer( iNeeded+1 );
char *buf = new char[iNeeded + 1];
vsnprintf( buf, iNeeded+1, szFormat, argList );
sStr.ReleaseBuffer( iNeeded );
return sStr;
RString ret(buf);
delete [] buf;
return ret;
}
int iChars = FMT_BLOCK_SIZE;
int iTry = 1;
while( 1 )
char *buf = new char[iChars];
for (;;)
{
// Grow more than linearly (e.g. 512, 1536, 3072, etc)
char *buf = sStr.GetBuffer(iChars);
int iUsed = vsnprintf(buf, iChars-1, szFormat, argList);
if( iUsed == -1 )
int used = vsnprintf( buf, iChars - 1, szFormat, argList );
if ( used == -1 )
{
iChars += ((iTry+1) * FMT_BLOCK_SIZE);
sStr.ReleaseBuffer();
++iTry;
iChars += ( ++iTry * FMT_BLOCK_SIZE );
delete [] buf;
continue;
}
/* OK */
sStr.ReleaseBuffer(iUsed);
sStr.assign( buf, used );
delete [] buf;
break;
}
#endif
@@ -2149,12 +2149,11 @@ RString Capitalize( const RString &s )
if( s.empty() )
return RString();
RString s2 = s;
char *pBuf = s2.GetBuffer();
UnicodeDoUpper( pBuf, s2.size(), g_UpperCase );
s2.ReleaseBuffer();
char *buf = const_cast<char *>(s.c_str());
UnicodeDoUpper( buf, s.size(), g_UpperCase );
return s2;
return buf;
}
unsigned char g_UpperCase[256] =