As suggested, extract strlen calls from sizes into variables so it isn't called twice

This commit is contained in:
Glenn Smith 2018-03-08 20:59:40 -05:00
parent eab086e184
commit 47d5b6ead7
33 changed files with 171 additions and 114 deletions

View file

@ -547,8 +547,9 @@ const char * Component::getDescriptionText(const char *desc)
// [tom, 1/12/2007] If it isn't a file, just do it the easy way
if (!Platform::isFile(desc))
{
newDesc = new char[dStrlen(desc) + 1];
dStrcpy(newDesc, desc, dStrlen(desc) + 1);
dsize_t newDescLen = dStrlen(desc) + 1;
newDesc = new char[newDescLen];
dStrcpy(newDesc, desc, newDescLen);
return newDesc;
}

View file

@ -594,8 +594,9 @@ bool ParticleData::preload(bool server, String &errorStr)
animTexFrames.clear();
char* tokCopy = new char[dStrlen(animTexFramesString) + 1];
dStrcpy(tokCopy, animTexFramesString, dStrlen(animTexFramesString) + 1);
dsize_t tokLen = dStrlen(animTexFramesString) + 1;
char* tokCopy = new char[tokLen];
dStrcpy(tokCopy, animTexFramesString, tokLen);
char* currTok = dStrtok(tokCopy, " \t");
while (currTok != NULL)

View file

@ -608,8 +608,9 @@ bool ParticleEmitterData::onAdd()
// First we parse particleString into a list of particle name tokens
Vector<char*> dataBlocks(__FILE__, __LINE__);
char* tokCopy = new char[dStrlen(particleString) + 1];
dStrcpy(tokCopy, particleString, dStrlen(particleString) + 1);
dsize_t tokLen = dStrlen(particleString) + 1;
char* tokCopy = new char[tokLen];
dStrcpy(tokCopy, particleString, tokLen);
char* currTok = dStrtok(tokCopy, " \t");
while (currTok != NULL)

View file

@ -446,8 +446,9 @@ bool afxMagicMissileData::onAdd()
Vector<char*> dataBlocks(__FILE__, __LINE__);
// make a copy of points_string
char* tokCopy = new char[dStrlen(wiggle_axis_string) + 1];
dStrcpy(tokCopy, wiggle_axis_string, dStrlen(wiggle_axis_string) + 1);
dsize_t tokCopyLen = dStrlen(wiggle_axis_string) + 1;
char* tokCopy = new char[tokCopyLen];
dStrcpy(tokCopy, wiggle_axis_string, tokCopyLen);
// extract tokens one by one, adding them to dataBlocks
char* currTok = dStrtok(tokCopy, " \t");

View file

@ -141,8 +141,9 @@ bool afxParticleEmitterData::onAdd()
if (tpaths_string != ST_NULLSTRING)
{
Vector<char*> dataBlocks(__FILE__, __LINE__);
char* tokCopy = new char[dStrlen(tpaths_string) + 1];
dStrcpy(tokCopy, tpaths_string, dStrlen(tpaths_string) + 1);
dsize_t tokCopyLen = dStrlen(tpaths_string) + 1;
char* tokCopy = new char[tokCopyLen];
dStrcpy(tokCopy, tpaths_string, tokCopyLen);
char* currTok = dStrtok(tokCopy, " \t");
while (currTok != NULL)
@ -467,8 +468,9 @@ bool afxParticleEmitterPathData::onAdd()
if (epaths_string != ST_NULLSTRING)
{
Vector<char*> dataBlocks(__FILE__, __LINE__);
char* tokCopy = new char[dStrlen(epaths_string) + 1];
dStrcpy(tokCopy, epaths_string, dStrlen(epaths_string) + 1);
dsize_t tokCopyLen = dStrlen(epaths_string) + 1;
char* tokCopy = new char[tokCopyLen];
dStrcpy(tokCopy, epaths_string, tokCopyLen);
char* currTok = dStrtok(tokCopy, " \t");
while (currTok != NULL)
@ -552,8 +554,9 @@ void afxParticleEmitterPathData::onPerformSubstitutions()
if (epaths_string != ST_NULLSTRING)
{
Vector<char*> dataBlocks(__FILE__, __LINE__);
char* tokCopy = new char[dStrlen(epaths_string) + 1];
dStrcpy(tokCopy, epaths_string, dStrlen(epaths_string) + 1);
dsize_t tokCopyLen = dStrlen(epaths_string) + 1;
char* tokCopy = new char[tokCopyLen];
dStrcpy(tokCopy, epaths_string, tokCopyLen);
char* currTok = dStrtok(tokCopy, " \t");
while (currTok != NULL)

View file

@ -194,8 +194,9 @@ bool afxXM_PathConformData::onAdd()
if (paths_string != ST_NULLSTRING)
{
Vector<char*> dataBlocks(__FILE__, __LINE__);
char* tokCopy = new char[dStrlen(paths_string) + 1];
dStrcpy(tokCopy, paths_string, dStrlen(paths_string) + 1);
dsize_t tokCopyLen = dStrlen(paths_string) + 1;
char* tokCopy = new char[tokCopyLen];
dStrcpy(tokCopy, paths_string, tokCopyLen);
char* currTok = dStrtok(tokCopy, " \t");
while (currTok != NULL)

View file

@ -286,8 +286,9 @@ DefineEngineFunction(filterString, const char *, (const char* baseString, const
else
replaceStr = gBadWordFilter->getDefaultReplaceStr();
char *ret = Con::getReturnBuffer(dStrlen(baseString) + 1);
dStrcpy(ret, baseString, dStrlen(baseString) + 1);
dsize_t retLen = dStrlen(baseString) + 1;
char *ret = Con::getReturnBuffer(retLen);
dStrcpy(ret, baseString, retLen);
gBadWordFilter->filterString(ret, replaceStr);
return ret;
}

View file

@ -510,14 +510,16 @@ void queryMasterServer(U8 flags, const char* gameType, const char* missionType,
// Update the active filter:
if ( !sActiveFilter.gameType || dStrcmp( sActiveFilter.gameType, gameType ) != 0 )
{
sActiveFilter.gameType = (char*) dRealloc( sActiveFilter.gameType, dStrlen( gameType ) + 1 );
dStrcpy( sActiveFilter.gameType, gameType, dStrlen(gameType) + 1 );
dsize_t gameTypeLen = dStrlen(gameType) + 1;
sActiveFilter.gameType = (char*) dRealloc( sActiveFilter.gameType, gameTypeLen );
dStrcpy( sActiveFilter.gameType, gameType, gameTypeLen );
}
if ( !sActiveFilter.missionType || dStrcmp( sActiveFilter.missionType, missionType ) != 0 )
{
sActiveFilter.missionType = (char*) dRealloc( sActiveFilter.missionType, dStrlen( missionType ) + 1 );
dStrcpy( sActiveFilter.missionType, missionType, dStrlen(missionType) + 1 );
dsize_t missionTypeLen = dStrlen(missionType) + 1;
sActiveFilter.missionType = (char*) dRealloc( sActiveFilter.missionType, missionTypeLen );
dStrcpy( sActiveFilter.missionType, missionType, missionTypeLen );
}
sActiveFilter.queryFlags = flags | ServerFilter::NewStyleResponse;
@ -969,8 +971,9 @@ static void pushServerFavorites()
Net::stringToAddress( addrString, &addr );
ServerInfo* si = findOrCreateServerInfo( &addr );
AssertFatal(si, "pushServerFavorites - failed to create Server Info!" );
si->name = (char*) dRealloc( (void*) si->name, dStrlen( serverName ) + 1 );
dStrcpy( si->name, serverName, dStrlen(serverName) + 1 );
dsize_t nameLen = dStrlen(serverName) + 1;
si->name = (char*) dRealloc( (void*) si->name, nameLen );
dStrcpy( si->name, serverName, nameLen );
si->isFavorite = true;
pushPingRequest( &addr );
}
@ -1053,8 +1056,9 @@ void addFakeServers( S32 howMany )
newServer.maxPlayers = 64;
char buf[256];
dSprintf( buf, 255, "Fake server #%d", sNumFakeServers );
newServer.name = (char*) dMalloc( dStrlen( buf ) + 1 );
dStrcpy( newServer.name, buf, strlen(buf) + 1 );
dsize_t nameLen = dStrlen(buf) + 1;
newServer.name = (char*) dMalloc( nameLen );
dStrcpy( newServer.name, buf, nameLen );
newServer.gameType = (char*) dMalloc( 5 );
dStrcpy( newServer.gameType, "Fake", 5 );
newServer.missionType = (char*) dMalloc( 16 );
@ -1753,8 +1757,9 @@ static void handleGameMasterInfoRequest( const NetAddress* address, U32 key, U8
out->write( playerCount );
const char* guidList = Con::getVariable( "Server::GuidList" );
char* buf = new char[dStrlen( guidList ) + 1];
dStrcpy( buf, guidList, dStrlen(guidList) + 1 );
dsize_t bufLen = dStrlen(guidList) + 1;
char* buf = new char[bufLen];
dStrcpy( buf, guidList, bufLen );
char* temp = dStrtok( buf, "\t" );
temp8 = 0;
for ( ; temp && temp8 < playerCount; temp8++ )
@ -1948,8 +1953,9 @@ static void handleGamePingResponse( const NetAddress* address, BitStream* stream
stream->readString( buf );
if ( !si->name )
{
si->name = (char*) dMalloc( dStrlen( buf ) + 1 );
dStrcpy( si->name, buf, dStrlen(buf) + 1 );
dsize_t bufLen = dStrlen(buf) + 1;
si->name = (char*) dMalloc(bufLen);
dStrcpy( si->name, buf, bufLen );
}
// Set the server up to be queried:
@ -2050,8 +2056,9 @@ static void handleGameInfoResponse( const NetAddress* address, BitStream* stream
stream->readString( stringBuf );
if ( !si->gameType || dStricmp( si->gameType, stringBuf ) != 0 )
{
si->gameType = (char*) dRealloc( (void*) si->gameType, dStrlen( stringBuf ) + 1 );
dStrcpy( si->gameType, stringBuf, dStrlen(stringBuf) + 1 );
dsize_t gameTypeLen = dStrlen(stringBuf) + 1;
si->gameType = (char*) dRealloc( (void*) si->gameType, gameTypeLen );
dStrcpy( si->gameType, stringBuf, gameTypeLen );
// Test against the active filter:
if ( applyFilter && dStricmp( sActiveFilter.gameType, "any" ) != 0
@ -2067,8 +2074,9 @@ static void handleGameInfoResponse( const NetAddress* address, BitStream* stream
stream->readString( stringBuf );
if ( !si->missionType || dStrcmp( si->missionType, stringBuf ) != 0 )
{
si->missionType = (char*) dRealloc( (void*) si->missionType, dStrlen( stringBuf ) + 1 );
dStrcpy( si->missionType, stringBuf, dStrlen(stringBuf) + 1 );
dsize_t missionTypeLen = dStrlen(stringBuf) + 1;
si->missionType = (char*) dRealloc( (void*) si->missionType, missionTypeLen );
dStrcpy( si->missionType, stringBuf, missionTypeLen );
// Test against the active filter:
if ( applyFilter && dStricmp( sActiveFilter.missionType, "any" ) != 0
@ -2088,8 +2096,9 @@ static void handleGameInfoResponse( const NetAddress* address, BitStream* stream
*temp = '\0';
if ( !si->missionName || dStrcmp( si->missionName, stringBuf ) != 0 )
{
si->missionName = (char*) dRealloc( (void*) si->missionName, dStrlen( stringBuf ) + 1 );
dStrcpy( si->missionName, stringBuf, dStrlen(stringBuf) + 1 );
dsize_t missionNameLen = dStrlen(stringBuf) + 1;
si->missionName = (char*) dRealloc( (void*) si->missionName, missionNameLen );
dStrcpy( si->missionName, stringBuf, missionNameLen );
}
// Get the server status:
@ -2157,16 +2166,18 @@ static void handleGameInfoResponse( const NetAddress* address, BitStream* stream
stream->readString( stringBuf );
if ( !si->statusString || ( isUpdate && dStrcmp( si->statusString, stringBuf ) != 0 ) )
{
si->infoString = (char*) dRealloc( (void*) si->infoString, dStrlen( stringBuf ) + 1 );
dStrcpy( si->infoString, stringBuf, dStrlen(stringBuf) + 1 );
dsize_t infoLen = dStrlen(stringBuf) + 1;
si->infoString = (char*) dRealloc( (void*) si->infoString, infoLen );
dStrcpy( si->infoString, stringBuf, infoLen );
}
// Get the content string:
readLongCString( stream, stringBuf );
if ( !si->statusString || ( isUpdate && dStrcmp( si->statusString, stringBuf ) != 0 ) )
{
si->statusString = (char*) dRealloc( (void*) si->statusString, dStrlen( stringBuf ) + 1 );
dStrcpy( si->statusString, stringBuf, dStrlen(stringBuf) + 1 );
dsize_t statusLen = dStrlen(stringBuf) + 1;
si->statusString = (char*) dRealloc( (void*) si->statusString, statusLen );
dStrcpy( si->statusString, stringBuf, statusLen );
}
// Update the server browser gui!

View file

@ -182,8 +182,9 @@ extern "C" {
void torque_setexecutablepath(const char* directory)
{
gExecutablePath = new char[dStrlen(directory)+1];
dStrcpy(gExecutablePath, directory, dStrlen(directory)+1);
dsize_t pathLen = dStrlen(directory) + 1;
gExecutablePath = new char[pathLen];
dStrcpy(gExecutablePath, directory, pathLen);
}
// set Torque 3D into web deployment mode (disable fullscreen exlusive mode, etc)

View file

@ -2340,8 +2340,9 @@ static int Sc_ScanString(int ret)
if (!collapseEscape(CMDtext + 1))
return -1;
char* buffer = (char*)consoleAlloc(dStrlen(CMDtext));
dStrcpy(buffer, CMDtext + 1, dStrlen(CMDtext));
dsize_t bufferLen = dStrlen(CMDtext);
char* buffer = (char*)consoleAlloc(bufferLen);
dStrcpy(buffer, CMDtext + 1, bufferLen);
CMDlval.str = MakeToken< char* >(buffer, lineIndex);
return ret;

View file

@ -412,8 +412,9 @@ static int Sc_ScanString(int ret)
if(!collapseEscape(CMDtext+1))
return -1;
char* buffer = ( char* ) consoleAlloc( dStrlen( CMDtext ) );
dStrcpy( buffer, CMDtext + 1, dStrlen( CMDtext ) );
dsize_t bufferLen = dStrlen( CMDtext );
char* buffer = ( char* ) consoleAlloc( bufferLen );
dStrcpy( buffer, CMDtext + 1, bufferLen );
CMDlval.str = MakeToken< char* >( buffer, lineIndex );
return ret;

View file

@ -238,10 +238,11 @@ StrConstNode *StrConstNode::alloc(S32 lineNumber, char *str, bool tag, bool doc)
StrConstNode *ret = (StrConstNode *)consoleAlloc(sizeof(StrConstNode));
constructInPlace(ret);
ret->dbgLineNumber = lineNumber;
ret->str = (char *)consoleAlloc(dStrlen(str) + 1);
dsize_t retStrLen = dStrlen(str) + 1;
ret->str = (char *)consoleAlloc(retStrLen);
ret->tag = tag;
ret->doc = doc;
dStrcpy(ret->str, str, dStrlen(str) + 1);
dStrcpy(ret->str, str, retStrLen);
return ret;
}

View file

@ -646,8 +646,9 @@ static void _printf(ConsoleLogEntry::Level level, ConsoleLogEntry::Type type, co
entry.mLevel = level;
entry.mType = type;
#ifndef TORQUE_SHIPPING // this is equivalent to a memory leak, turn it off in ship build
entry.mString = (const char *)consoleLogChunker.alloc(dStrlen(pos) + 1);
dStrcpy(const_cast<char*>(entry.mString), pos, dStrlen(pos) + 1);
dsize_t logStringLen = dStrlen(pos) + 1;
entry.mString = (const char *)consoleLogChunker.alloc(logStringLen);
dStrcpy(const_cast<char*>(entry.mString), pos, logStringLen);
// This prevents infinite recursion if the console itself needs to
// re-allocate memory to accommodate the new console log entry, and

View file

@ -585,8 +585,9 @@ DefineConsoleFunction( strlwr, const char*, ( const char* str ),,
"@see strupr\n"
"@ingroup Strings" )
{
char *ret = Con::getReturnBuffer(dStrlen(str) + 1);
dStrcpy(ret, str, dStrlen(str) + 1);
dsize_t retLen = dStrlen(str) + 1;
char *ret = Con::getReturnBuffer(retLen);
dStrcpy(ret, str, retLen);
return dStrlwr(ret);
}
@ -602,8 +603,9 @@ DefineConsoleFunction( strupr, const char*, ( const char* str ),,
"@see strlwr\n"
"@ingroup Strings" )
{
char *ret = Con::getReturnBuffer(dStrlen(str) + 1);
dStrcpy(ret, str, dStrlen(str) + 1);
dsize_t retLen = dStrlen(str) + 1;
char *ret = Con::getReturnBuffer(retLen);
dStrcpy(ret, str, retLen);
return dStrupr(ret);
}
@ -1826,8 +1828,9 @@ DefineEngineFunction( detag, const char*, ( const char* str ),,
if( word == NULL )
return "";
char* ret = Con::getReturnBuffer( dStrlen( word + 1 ) + 1 );
dStrcpy( ret, word + 1, dStrlen(word + 1) + 1 );
dsize_t retLen = dStrlen(word + 1) + 1;
char* ret = Con::getReturnBuffer(retLen);
dStrcpy( ret, word + 1, retLen );
return ret;
}
else

View file

@ -617,8 +617,9 @@ DefineEngineFunction(fileBase, String, ( const char* fileName ),,
path = szPathCopy;
else
path++;
char *ret = Con::getReturnBuffer(dStrlen(path) + 1);
dStrcpy(ret, path, dStrlen(path) + 1);
dsize_t retLen = dStrlen(path) + 1;
char *ret = Con::getReturnBuffer(retLen);
dStrcpy(ret, path, retLen);
char *ext = dStrrchr(ret, '.');
if(ext)
*ext = 0;
@ -643,8 +644,9 @@ DefineEngineFunction(fileName, String, ( const char* fileName ),,
name = szPathCopy;
else
name++;
char *ret = Con::getReturnBuffer(dStrlen(name) + 1);
dStrcpy(ret, name, dStrlen(name) + 1);
dsize_t retLen = dStrlen(name) + 1;
char *ret = Con::getReturnBuffer(retLen);
dStrcpy(ret, name, retLen);
return ret;
}

View file

@ -134,10 +134,11 @@ SimObject *SimObjectMemento::restore() const
return NULL;
U32 numCharsToLeftParen = pLeftParen - mState;
tempBuffer = ( char* ) dMalloc( dStrlen( mState ) + uniqueNameLen + 1 );
dsize_t tempBufferLen = dStrlen(mState) + uniqueNameLen + 1;
tempBuffer = ( char* ) dMalloc( tempBufferLen );
dMemcpy( tempBuffer, mState, numCharsToLeftParen );
dMemcpy( &tempBuffer[ numCharsToLeftParen ], uniqueName, uniqueNameLen );
dStrcpy( &tempBuffer[ numCharsToLeftParen + uniqueNameLen ], &mState[ numCharsToLeftParen ], dStrlen(mState) - numCharsToLeftParen + 1 );
dStrcpy( &tempBuffer[ numCharsToLeftParen + uniqueNameLen ], &mState[ numCharsToLeftParen ], tempBufferLen - numCharsToLeftParen - uniqueNameLen );
}
Con::evaluate( tempBuffer );

View file

@ -142,10 +142,11 @@ StringTableEntry _StringTable::insert(const char* _val, const bool caseSens)
}
char *ret = 0;
if(!*walk) {
dsize_t valLen = dStrlen(val) + 1;
*walk = (Node *) mempool.alloc(sizeof(Node));
(*walk)->next = 0;
(*walk)->val = (char *) mempool.alloc(dStrlen(val) + 1);
dStrcpy((*walk)->val, val, dStrlen(val) + 1);
(*walk)->val = (char *) mempool.alloc(valLen);
dStrcpy((*walk)->val, val, valLen);
ret = (*walk)->val;
itemCount ++;
}

View file

@ -71,8 +71,9 @@ void FindMatch::setExpression( const char *_expression )
{
delete [] expression;
expression = new char[dStrlen(_expression) + 1];
dStrcpy(expression, _expression, dStrlen(_expression) + 1);
dsize_t expressionLen = dStrlen(_expression) + 1;
expression = new char[expressionLen];
dStrcpy(expression, _expression, expressionLen);
dStrupr(expression);
}

View file

@ -215,8 +215,9 @@ S32 dStrnatcasecmp(const nat_char* a, const nat_char* b) {
char *dStrdup_r(const char *src, const char *fileName, dsize_t lineNumber)
{
char *buffer = (char *) dMalloc_r(dStrlen(src) + 1, fileName, lineNumber);
dStrcpy(buffer, src, dStrlen(src) + 1);
dsize_t bufferLen = dStrlen(src) + 1;
char *buffer = (char *) dMalloc_r(bufferLen, fileName, lineNumber);
dStrcpy(buffer, src, bufferLen);
return buffer;
}

View file

@ -177,8 +177,9 @@ bool CentralDir::write(Stream *stream)
void CentralDir::setFileComment(const char *comment)
{
SAFE_DELETE_ARRAY(mFileComment);
mFileComment = new char [dStrlen(comment)+1];
dStrcpy(mFileComment, comment, dStrlen(comment)+1);
dsize_t commentLen = dStrlen(comment) + 1;
mFileComment = new char [commentLen];
dStrcpy(mFileComment, comment, commentLen);
}
//-----------------------------------------------------------------------------

View file

@ -39,8 +39,9 @@ void GFXVideoMode::parseFromString( const char *str )
return;
// Copy the string, as dStrtok is destructive
char *tempBuf = new char[dStrlen( str ) + 1];
dStrcpy( tempBuf, str, dStrlen(str) + 1 );
dsize_t tempBufLen = dStrlen(str) + 1;
char *tempBuf = new char[tempBufLen];
dStrcpy( tempBuf, str, tempBufLen );
#define PARSE_ELEM(type, var, func, tokParam, sep) \
if(const char *ptr = dStrtok( tokParam, sep)) \

View file

@ -167,8 +167,9 @@ bool guiAnimBitmapCtrl::ptSetFrameRanges(void *object, const char *index, const
pData->mCurFrameIndex = pData->mNumFrames;
return true;
}
char* tokCopy = new char[dStrlen(data) + 1];
dStrcpy(tokCopy, data, dStrlen(data) + 1);
dsize_t tokLen = dStrlen(data) + 1;
char* tokCopy = new char[tokLen];
dStrcpy(tokCopy, data, tokLen);
char* currTok = dStrtok(tokCopy, " \t");
while (currTok != NULL)

View file

@ -42,8 +42,9 @@ LangFile::LangFile(const UTF8 *langName /* = NULL */)
if(langName)
{
mLangName = new UTF8 [dStrlen(langName) + 1];
dStrcpy(mLangName, langName, dStrlen(langName) + 1);
dsize_t langNameLen = dStrlen(langName) + 1;
mLangName = new UTF8 [langNameLen];
dStrcpy(mLangName, langName, langNameLen);
}
else
mLangName = NULL;
@ -136,8 +137,9 @@ const UTF8 * LangFile::getString(U32 id)
U32 LangFile::addString(const UTF8 *str)
{
UTF8 *newstr = new UTF8 [dStrlen(str) + 1];
dStrcpy(newstr, str, dStrlen(str) + 1);
dsize_t newstrLen = dStrlen(str) + 1;
UTF8 *newstr = new UTF8 [newstrLen];
dStrcpy(newstr, str, newstrLen);
mStringTable.push_back(newstr);
return mStringTable.size() - 1;
}
@ -156,8 +158,9 @@ void LangFile::setString(U32 id, const UTF8 *str)
SAFE_DELETE_ARRAY(mStringTable[id]);
UTF8 *newstr = new UTF8 [dStrlen(str) + 1];
dStrcpy(newstr, str, dStrlen(str) + 1);
dsize_t newstrLen = dStrlen(str) + 1;
UTF8 *newstr = new UTF8 [newstrLen];
dStrcpy(newstr, str, newstrLen);
mStringTable[id] = newstr;
}
@ -166,8 +169,9 @@ void LangFile::setLangName(const UTF8 *newName)
if(mLangName)
delete [] mLangName;
mLangName = new UTF8 [dStrlen(newName) + 1];
dStrcpy(mLangName, newName, dStrlen(newName) + 1);
dsize_t langNameLen = dStrlen(newName) + 1;
mLangName = new UTF8 [langNameLen];
dStrcpy(mLangName, newName, langNameLen);
}
void LangFile::setLangFile(const UTF8 *langFile)
@ -175,8 +179,9 @@ void LangFile::setLangFile(const UTF8 *langFile)
if(mLangFile)
delete [] mLangFile;
mLangFile = new UTF8 [dStrlen(langFile) + 1];
dStrcpy(mLangFile, langFile, dStrlen(langFile) + 1);
dsize_t langFileLen = dStrlen(langFile) + 1;
mLangFile = new UTF8 [langFileLen];
dStrcpy(mLangFile, langFile, langFileLen);
}
bool LangFile::activateLanguage()
@ -349,8 +354,9 @@ DefineConsoleMethod(LangTable, getString, const char *, (U32 id), ,
const char * str = (const char*)object->getString(id);
if(str != NULL)
{
char * ret = Con::getReturnBuffer(dStrlen(str) + 1);
dStrcpy(ret, str, dStrlen(str) + 1);
dsize_t retLen = dStrlen(str) + 1;
char * ret = Con::getReturnBuffer(retLen);
dStrcpy(ret, str, retLen);
return ret;
}
@ -387,8 +393,9 @@ DefineConsoleMethod(LangTable, getLangName, const char *, (S32 langId), , "(int
const char * str = (const char*)object->getLangName(langId);
if(str != NULL)
{
char * ret = Con::getReturnBuffer(dStrlen(str) + 1);
dStrcpy(ret, str, dStrlen(str) + 1);
dsize_t retLen = dStrlen(str) + 1;
char * ret = Con::getReturnBuffer(retLen);
dStrcpy(ret, str, retLen);
return ret;
}

View file

@ -53,8 +53,9 @@ public:
mName = name;
// Allocate and copy the value.
mpValue = new char[ dStrlen(pValue)+1 ];
dStrcpy( (char *)mpValue, pValue, dStrlen(pValue) + 1 );
dsize_t valueLen = dStrlen(pValue) + 1;
mpValue = new char[ valueLen ];
dStrcpy( (char *)mpValue, pValue, valueLen );
}

View file

@ -1575,8 +1575,9 @@ const char* DInputDevice::getJoystickAxesString()
}
}
char* returnString = Con::getReturnBuffer( dStrlen( buf ) + 1 );
dStrcpy( returnString, buf, dStrlen(buf) + 1 );
dsize_t returnLen = dStrlen(buf) + 1;
char* returnString = Con::getReturnBuffer(returnLen);
dStrcpy( returnString, buf, returnLen );
return( returnString );
}

View file

@ -83,8 +83,9 @@ void installRedBookDevices()
if(::GetDriveTypeA(str) == DRIVE_CDROM)
{
Win32RedBookDevice * device = new Win32RedBookDevice;
device->mDeviceName = new char[dStrlen(str) + 1];
dStrcpy(device->mDeviceName, str, dStrlen(str) + 1);
dsize_t deviceNameLen = dStrlen(str) + 1;
device->mDeviceName = new char[deviceNameLen];
dStrcpy(device->mDeviceName, str, deviceNameLen);
RedBook::installDevice(device);
}

View file

@ -40,8 +40,9 @@ bool InitOpenGL()
// Get the video settings from the prefs:
const char* resString = Con::getVariable( "$pref::Video::resolution" );
char* tempBuf = new char[dStrlen( resString ) + 1];
dStrcpy( tempBuf, resString, dStrlen(resString) + 1 );
dsize_t tempBufLen = dStrlen(resString) + 1;
char* tempBuf = new char[tempBufLen];
dStrcpy( tempBuf, resString, tempBufLen );
char* temp = dStrtok( tempBuf, " x\0" );
U32 width = ( temp ? dAtoi( temp ) : 800 );
temp = dStrtok( NULL, " x\0" );

View file

@ -101,8 +101,9 @@ void UnixRedBookDevice::setDeviceInfo(S32 deviceId, const char *deviceName)
{
#if !defined(__FreeBSD__)
mDeviceId = deviceId;
mDeviceName = new char[dStrlen(deviceName) + 1];
dStrcpy(mDeviceName, deviceName, dStrlen(deviceName) + 1);
dsize_t deviceNameLen = dStrlen(deviceName) + 1;
mDeviceName = new char[deviceNameLen];
dStrcpy(mDeviceName, deviceName, deviceNameLen);
#endif // !defined(__FreeBSD__)
}

View file

@ -908,8 +908,9 @@ const char* ActionMap::getDeadZone( const char* device, const char* action )
{
char buf[64];
dSprintf( buf, sizeof( buf ), "%g %g", mapNode->deadZoneBegin, mapNode->deadZoneEnd );
char* returnString = Con::getReturnBuffer( dStrlen( buf ) + 1 );
dStrcpy( returnString, buf, dStrlen(buf) + 1 );
dsize_t returnLen = dStrlen(buf) + 1;
char* returnString = Con::getReturnBuffer( returnLen );
dStrcpy( returnString, buf, returnLen );
return( returnString );
}
else

View file

@ -96,8 +96,9 @@ U32 NetStringTable::addString(const char *string)
size = newSize;
}
table[e].refCount++;
table[e].string = (char *) allocator->alloc(dStrlen(string) + 1);
dStrcpy(table[e].string, string, dStrlen(string) + 1);
dsize_t stringLen = dStrlen(string) + 1;
table[e].string = (char *) allocator->alloc(stringLen);
dStrcpy(table[e].string, string, stringLen);
table[e].next = hashTable[bucket];
hashTable[bucket] = e;
table[e].link = firstValid;
@ -178,8 +179,9 @@ void NetStringTable::repack()
const char *prevStr = table[walk].string;
table[walk].string = (char *) newAllocator->alloc(dStrlen(prevStr) + 1);
dStrcpy(table[walk].string, prevStr, dStrlen(prevStr) + 1);
dsize_t prevStrLen = dStrlen(prevStr) + 1;
table[walk].string = (char *) newAllocator->alloc(prevStrLen);
dStrcpy(table[walk].string, prevStr, prevStrLen);
}
delete allocator;
allocator = newAllocator;

View file

@ -157,13 +157,15 @@ S32 Callback(void *pArg, S32 argc, char **argv, char **columnNames)
{
// DBEUG CODE
// Con::printf("%s = %s\n", columnNames[i], argv[i] ? argv[i] : "NULL");
name = new char[dStrlen(columnNames[i]) + 1];
dStrcpy(name, columnNames[i], dStrlen(columnNames[i]) + 1);
dsize_t columnNameLen = dStrlen(columnNames[i]) + 1;
name = new char[columnNameLen];
dStrcpy(name, columnNames[i], columnNameLen);
pRow->vColumnNames.push_back(name);
if (argv[i])
{
value = new char[dStrlen(argv[i]) + 1];
dStrcpy(value, argv[i], dStrlen(argv[i]) + 1);
dsize_t valueLen = dStrlen(argv[i]) + 1;
value = new char[valueLen];
dStrcpy(value, argv[i], valueLen);
pRow->vColumnValues.push_back(value);
}
else

View file

@ -288,8 +288,9 @@ bool EventManager::subscribe(SimObject *callbackObj, const char* event, const ch
}
else
{
cb = new char[dStrlen(callback) + 1];
dStrcpy(cb, callback, dStrlen(callback) + 1);
dsize_t cbLen = dStrlen(callback) + 1;
cb = new char[cbLen];
dStrcpy(cb, callback, cbLen);
}
// Create the subscriber object.

View file

@ -545,8 +545,9 @@ DefineConsoleMethod(UndoManager, getNextUndoName, const char *, (),, "UndoManage
const char *name = object->getNextUndoName();
if(!name)
return NULL;
char *ret = Con::getReturnBuffer(dStrlen(name) + 1);
dStrcpy(ret, name, dStrlen(name) + 1);
dsize_t retLen = dStrlen(name) + 1;
char *ret = Con::getReturnBuffer(retLen);
dStrcpy(ret, name, retLen);
return ret;
}
@ -556,8 +557,9 @@ DefineConsoleMethod(UndoManager, getNextRedoName, const char *, (),, "UndoManage
const char *name = object->getNextRedoName();
if(!name)
return NULL;
char *ret = Con::getReturnBuffer(dStrlen(name) + 1);
dStrcpy(ret, name, dStrlen(name) + 1);
dsize_t retLen = dStrlen(name) + 1;
char *ret = Con::getReturnBuffer(retLen);
dStrcpy(ret, name, retLen);
return ret;
}