mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-26 07:39:27 +00:00
Rename the memory allocating versions to make prev error less likely
The behavior is different enough that these shouldn't be overloaded with the non-allocating verions. Also makes it more obvious what is going on to the caller.
This commit is contained in:
parent
d669eb6ee7
commit
fcf52fb5e0
9 changed files with 17 additions and 17 deletions
|
|
@ -186,7 +186,7 @@ void StringBuffer::append(const UTF8* in)
|
|||
|
||||
// convert to UTF16, because that's our internal format.
|
||||
// if the conversion fails, exit.
|
||||
UTF16* tmp = convertUTF8toUTF16(in);
|
||||
UTF16* tmp = createUTF16string(in);
|
||||
AssertFatal(tmp, "StringBuffer::append(UTF8) - could not convert UTF8 string!");
|
||||
if(!tmp)
|
||||
return;
|
||||
|
|
@ -231,7 +231,7 @@ void StringBuffer::insert(const U32 charOffset, const UTF8* in)
|
|||
|
||||
// convert to UTF16, because that's our internal format.
|
||||
// if the conversion fails, exit.
|
||||
UTF16* tmp = convertUTF8toUTF16(in);
|
||||
UTF16* tmp = createUTF16string(in);
|
||||
AssertFatal(tmp, "StringBuffer::insert(UTF8) - could not convert UTF8 string!");
|
||||
if(!tmp)
|
||||
return;
|
||||
|
|
@ -377,7 +377,7 @@ UTF8* StringBuffer::createCopy8() const
|
|||
incRequestCount8();
|
||||
// convert will create a buffer of the appropriate size for a null terminated
|
||||
// input string.
|
||||
UTF8* out = convertUTF16toUTF8(mBuffer.address());
|
||||
UTF8* out = createUTF8string(mBuffer.address());
|
||||
return out;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -242,7 +242,7 @@ U32 convertUTF16toUTF8DoubleNULL( const UTF16 *unistring, UTF8 *outbuffer, U32
|
|||
//-----------------------------------------------------------------------------
|
||||
// Functions that convert buffers of unicode code points
|
||||
//-----------------------------------------------------------------------------
|
||||
UTF16* convertUTF8toUTF16( const UTF8* unistring)
|
||||
UTF16* createUTF16string( const UTF8* unistring)
|
||||
{
|
||||
PROFILE_SCOPE(convertUTF8toUTF16_create);
|
||||
|
||||
|
|
@ -264,7 +264,7 @@ UTF16* convertUTF8toUTF16( const UTF8* unistring)
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
UTF8* convertUTF16toUTF8( const UTF16* unistring)
|
||||
UTF8* createUTF8string( const UTF16* unistring)
|
||||
{
|
||||
PROFILE_SCOPE(convertUTF16toUTF8_create);
|
||||
|
||||
|
|
|
|||
|
|
@ -62,9 +62,9 @@
|
|||
/// calling delete[] on these buffers.
|
||||
/// - Because they allocate memory, do not use these functions in a tight loop.
|
||||
/// - These are useful when you need a new long term copy of a string.
|
||||
UTF16* convertUTF8toUTF16( const UTF8 *unistring);
|
||||
UTF16* createUTF16string( const UTF8 *unistring);
|
||||
|
||||
UTF8* convertUTF16toUTF8( const UTF16 *unistring);
|
||||
UTF8* createUTF8string( const UTF16 *unistring);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/// Functions that convert buffers of unicode code points, into a provided buffer.
|
||||
|
|
|
|||
|
|
@ -346,7 +346,7 @@ class String::StringData : protected StringDataImpl
|
|||
{
|
||||
// Do this atomically to protect interned strings.
|
||||
|
||||
UTF16* utf16 = convertUTF8toUTF16( mData );
|
||||
UTF16* utf16 = createUTF16string( mData );
|
||||
if( !dCompareAndSwap( mUTF16,( UTF16* ) NULL, utf16 ) )
|
||||
delete [] utf16;
|
||||
}
|
||||
|
|
@ -580,7 +580,7 @@ String::String(const UTF16 *str)
|
|||
|
||||
if( str && str[ 0 ] )
|
||||
{
|
||||
UTF8* utf8 = convertUTF16toUTF8( str );
|
||||
UTF8* utf8 = createUTF8string( str );
|
||||
U32 len = dStrlen( utf8 );
|
||||
_string = new ( len ) StringData( utf8 );
|
||||
delete [] utf8;
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ protected:
|
|||
: mData( str ), mLength( str ? dStrlen( str ) : 0 ), mUTF16( NULL )
|
||||
{
|
||||
if( str )
|
||||
mUTF16 = convertUTF8toUTF16( mData );
|
||||
mUTF16 = createUTF16string( mData );
|
||||
}
|
||||
~StrTest()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -279,7 +279,7 @@ void GuiTextEditCtrl::setText( const UTF16* txt)
|
|||
{
|
||||
if(txt && txt[0] != 0)
|
||||
{
|
||||
UTF8* txt8 = convertUTF16toUTF8( txt );
|
||||
UTF8* txt8 = createUTF8string( txt );
|
||||
Parent::setText( txt8 );
|
||||
delete[] txt8;
|
||||
mTextBuffer.set( txt );
|
||||
|
|
|
|||
|
|
@ -101,8 +101,8 @@ S32 Platform::messageBox(const UTF8 *title, const UTF8 *message, MBButtons butto
|
|||
pWindow->setCursorVisible(true);
|
||||
|
||||
#ifdef UNICODE
|
||||
const UTF16 *msg = convertUTF8toUTF16(message);
|
||||
const UTF16 *t = convertUTF8toUTF16(title);
|
||||
const UTF16 *msg = createUTF16string(message);
|
||||
const UTF16 *t = createUTF16string(title);
|
||||
#else
|
||||
const UTF8 *msg = message;
|
||||
const UTF8 *t = title;
|
||||
|
|
|
|||
|
|
@ -802,7 +802,7 @@ StringTableEntry Platform::getCurrentDirectory()
|
|||
forwardslash( buf );
|
||||
|
||||
#ifdef UNICODE
|
||||
char* utf8 = convertUTF16toUTF8( buf );
|
||||
char* utf8 = createUTF8string( buf );
|
||||
StringTableEntry result = StringTable->insert( utf8 );
|
||||
SAFE_DELETE_ARRAY( utf8 );
|
||||
return result;
|
||||
|
|
@ -847,8 +847,8 @@ static void getExecutableInfo( StringTableEntry* path, StringTableEntry* exe )
|
|||
if( delimiter )
|
||||
*delimiter = '\0';
|
||||
|
||||
char* pathBuf = convertUTF16toUTF8( cen_buf );
|
||||
char* exeBuf = convertUTF16toUTF8( delimiter + 1 );
|
||||
char* pathBuf = createUTF8string( cen_buf );
|
||||
char* exeBuf = createUTF8string( delimiter + 1 );
|
||||
|
||||
pathEntry = StringTable->insert( pathBuf );
|
||||
exeEntry = StringTable->insert( exeBuf );
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ static HCURSOR gCursorShape = NULL;
|
|||
void Win32CursorController::setCursorShape( const UTF8 *fileName, bool reload )
|
||||
{
|
||||
#ifdef UNICODE
|
||||
const UTF16 *lFileName = convertUTF8toUTF16( fileName );
|
||||
const UTF16 *lFileName = createUTF16string( fileName );
|
||||
#else
|
||||
const UTF8 *lFileName = fileName;
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue