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:
@@ -206,7 +206,7 @@ void FileTransfer::StartTransfer( TransferType type, const RString &sURL, const
|
|||||||
m_wSocket.SendData( sHeader.c_str(), sHeader.length() );
|
m_wSocket.SendData( sHeader.c_str(), sHeader.length() );
|
||||||
m_wSocket.SendData( "\r\n" );
|
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_sStatus = "Header Sent.";
|
||||||
m_wSocket.blocking = false;
|
m_wSocket.blocking = false;
|
||||||
|
|||||||
@@ -454,11 +454,11 @@ RString ReadString( RageFileBasic &f, int iSize, RString &sError )
|
|||||||
if( sError.size() != 0 )
|
if( sError.size() != 0 )
|
||||||
return RString();
|
return RString();
|
||||||
|
|
||||||
RString sBuf;
|
char *buf = new char[iSize];
|
||||||
char *pBuf = sBuf.GetBuffer( iSize );
|
FileReading::ReadBytes( f, buf, iSize, sError );
|
||||||
FileReading::ReadBytes( f, pBuf, iSize, sError );
|
RString ret(buf);
|
||||||
sBuf.ReleaseBuffer( iSize );
|
delete [] buf;
|
||||||
return sBuf;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FATAL_ERROR(s) \
|
#define FATAL_ERROR(s) \
|
||||||
|
|||||||
+16
-17
@@ -468,30 +468,30 @@ RString vssprintf( const char *szFormat, va_list argList )
|
|||||||
int iNeeded = vsnprintf( &ignore, 0, szFormat, tmp );
|
int iNeeded = vsnprintf( &ignore, 0, szFormat, tmp );
|
||||||
va_end(tmp);
|
va_end(tmp);
|
||||||
|
|
||||||
char *buf = sStr.GetBuffer( iNeeded+1 );
|
char *buf = new char[iNeeded + 1];
|
||||||
vsnprintf( buf, iNeeded+1, szFormat, argList );
|
vsnprintf( buf, iNeeded+1, szFormat, argList );
|
||||||
sStr.ReleaseBuffer( iNeeded );
|
RString ret(buf);
|
||||||
return sStr;
|
delete [] buf;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int iChars = FMT_BLOCK_SIZE;
|
int iChars = FMT_BLOCK_SIZE;
|
||||||
int iTry = 1;
|
int iTry = 1;
|
||||||
while( 1 )
|
char *buf = new char[iChars];
|
||||||
|
for (;;)
|
||||||
{
|
{
|
||||||
// Grow more than linearly (e.g. 512, 1536, 3072, etc)
|
// Grow more than linearly (e.g. 512, 1536, 3072, etc)
|
||||||
char *buf = sStr.GetBuffer(iChars);
|
int used = vsnprintf( buf, iChars - 1, szFormat, argList );
|
||||||
int iUsed = vsnprintf(buf, iChars-1, szFormat, argList);
|
if ( used == -1 )
|
||||||
|
|
||||||
if( iUsed == -1 )
|
|
||||||
{
|
{
|
||||||
iChars += ((iTry+1) * FMT_BLOCK_SIZE);
|
iChars += ( ++iTry * FMT_BLOCK_SIZE );
|
||||||
sStr.ReleaseBuffer();
|
delete [] buf;
|
||||||
++iTry;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* OK */
|
/* OK */
|
||||||
sStr.ReleaseBuffer(iUsed);
|
sStr.assign( buf, used );
|
||||||
|
delete [] buf;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -2149,12 +2149,11 @@ RString Capitalize( const RString &s )
|
|||||||
if( s.empty() )
|
if( s.empty() )
|
||||||
return RString();
|
return RString();
|
||||||
|
|
||||||
RString s2 = s;
|
char *buf = const_cast<char *>(s.c_str());
|
||||||
char *pBuf = s2.GetBuffer();
|
|
||||||
UnicodeDoUpper( pBuf, s2.size(), g_UpperCase );
|
|
||||||
s2.ReleaseBuffer();
|
|
||||||
|
|
||||||
return s2;
|
UnicodeDoUpper( buf, s.size(), g_UpperCase );
|
||||||
|
|
||||||
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char g_UpperCase[256] =
|
unsigned char g_UpperCase[256] =
|
||||||
|
|||||||
Reference in New Issue
Block a user