mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-24 22:59:24 +00:00
Merge branch 'Preview4_0' into str_cpp_memory_experiment
This commit is contained in:
commit
1e9aa8b86f
4161 changed files with 514029 additions and 215418 deletions
|
|
@ -371,7 +371,7 @@ void StringBuffer::getCopy(UTF16 *buff, const U32 buffSize) const
|
|||
AssertFatal(mBuffer.last() == 0, "StringBuffer::get UTF8 - not a null terminated string!");
|
||||
dMemcpy(buff, mBuffer.address(), sizeof(UTF16) * getMin(buffSize, (U32)mBuffer.size()));
|
||||
// ensure null termination.
|
||||
buff[buffSize-1] = NULL;
|
||||
buff[buffSize-1] = 0;
|
||||
}
|
||||
|
||||
UTF8* StringBuffer::createCopy8() const
|
||||
|
|
|
|||
|
|
@ -428,7 +428,7 @@ S32 dStrlcpy(char *dst, const char *src, dsize_t dstSize)
|
|||
S32 copyLen = srcLen;
|
||||
|
||||
//Check for buffer overflow and don't allow it. Warn on debug so we can fix it
|
||||
AssertWarn(copyLen < dstSize, "Buffer too small in call to dStrlcpy!");
|
||||
AssertFatal(copyLen < dstSize, "Buffer too small in call to dStrlcpy!");
|
||||
if (srcLen + 1 > dstSize)
|
||||
{
|
||||
copyLen = dstSize - 1;
|
||||
|
|
|
|||
|
|
@ -200,6 +200,11 @@ inline F64 dAtod(const char *str)
|
|||
return strtod(str, NULL);
|
||||
}
|
||||
|
||||
inline S64 dAtol(const char* str)
|
||||
{
|
||||
return strtol(str, NULL, 10);
|
||||
}
|
||||
|
||||
inline char dToupper(const char c)
|
||||
{
|
||||
return toupper( c );
|
||||
|
|
|
|||
|
|
@ -236,8 +236,8 @@ U32 convertUTF16toUTF8DoubleNULL( const UTF16 *unistring, UTF8 *outbuffer, U32
|
|||
}
|
||||
|
||||
nCodeunits = getMin(nCodeunits,len - 1);
|
||||
outbuffer[nCodeunits] = NULL;
|
||||
outbuffer[nCodeunits+1] = NULL;
|
||||
outbuffer[nCodeunits] = '\0';
|
||||
outbuffer[nCodeunits+1] = '\0';
|
||||
|
||||
PROFILE_END();
|
||||
return nCodeunits;
|
||||
|
|
|
|||
|
|
@ -109,7 +109,10 @@ void Tokenizer::setBuffer(const char* buffer, U32 bufferSize)
|
|||
void Tokenizer::setSingleTokens(const char* singleTokens)
|
||||
{
|
||||
if (mSingleTokens)
|
||||
SAFE_DELETE(mSingleTokens);
|
||||
{
|
||||
free(mSingleTokens);
|
||||
mSingleTokens = NULL;
|
||||
}
|
||||
|
||||
if (singleTokens)
|
||||
mSingleTokens = dStrdup(singleTokens);
|
||||
|
|
|
|||
|
|
@ -48,8 +48,12 @@ Convert the byte ordering on the U16 to and from big/little endian format.
|
|||
|
||||
inline U16 endianSwap(const U16 in_swap)
|
||||
{
|
||||
#ifdef TORQUE_U16_ENDIANSWAP_BUILTIN
|
||||
return TORQUE_U16_ENDIANSWAP_BUILTIN(in_swap);
|
||||
#else
|
||||
return U16(((in_swap >> 8) & 0x00ff) |
|
||||
((in_swap << 8) & 0xff00));
|
||||
#endif
|
||||
}
|
||||
|
||||
inline S16 endianSwap(const S16 in_swap)
|
||||
|
|
@ -64,10 +68,14 @@ Convert the byte ordering on the U32 to and from big/little endian format.
|
|||
*/
|
||||
inline U32 endianSwap(const U32 in_swap)
|
||||
{
|
||||
#ifdef TORQUE_U32_ENDIANSWAP_BUILTIN
|
||||
return TORQUE_U32_ENDIANSWAP_BUILTIN(in_swap);
|
||||
#else
|
||||
return U32(((in_swap >> 24) & 0x000000ff) |
|
||||
((in_swap >> 8) & 0x0000ff00) |
|
||||
((in_swap << 8) & 0x00ff0000) |
|
||||
((in_swap << 24) & 0xff000000));
|
||||
#endif
|
||||
}
|
||||
|
||||
inline S32 endianSwap(const S32 in_swap)
|
||||
|
|
@ -77,12 +85,16 @@ inline S32 endianSwap(const S32 in_swap)
|
|||
|
||||
inline U64 endianSwap(const U64 in_swap)
|
||||
{
|
||||
#ifdef TORQUE_U64_ENDIANSWAP_BUILTIN
|
||||
return TORQUE_U64_ENDIANSWAP_BUILTIN(in_swap);
|
||||
#else
|
||||
U32 *inp = (U32 *) &in_swap;
|
||||
U64 ret;
|
||||
U32 *outp = (U32 *) &ret;
|
||||
outp[0] = endianSwap(inp[1]);
|
||||
outp[1] = endianSwap(inp[0]);
|
||||
return ret;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline S64 endianSwap(const S64 in_swap)
|
||||
|
|
@ -138,4 +150,3 @@ TORQUE_DECLARE_TEMPLATIZED_ENDIAN_CONV(F32)
|
|||
TORQUE_DECLARE_TEMPLATIZED_ENDIAN_CONV(F64)
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -30,9 +30,9 @@
|
|||
namespace Torque
|
||||
{
|
||||
|
||||
extern U32 hash(register const U8 *k, register U32 length, register U32 initval);
|
||||
extern U32 hash(const U8 *k, U32 length, U32 initval);
|
||||
|
||||
extern U64 hash64(register const U8 *k, register U32 length, register U64 initval);
|
||||
extern U64 hash64(const U8 *k, U32 length, U64 initval);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -287,9 +287,9 @@ class String::StringData : protected StringDataImpl
|
|||
|
||||
static StringData* Create(const StringChar* data, U32 len, bool interned = false)
|
||||
{
|
||||
void* memory = dMalloc(sizeof(StringData) + sizeof(StringChar) * len);
|
||||
StringData* result = new(memory) StringData(data, len, interned);
|
||||
return result;
|
||||
void* memory = dMalloc(sizeof(StringData) + sizeof(StringChar) * len)
|
||||
StringData* result = new(memory) StringData(data, len, interned);
|
||||
return result;
|
||||
}
|
||||
|
||||
static StringData* Create(const StringChar* data, U32 len, DataChunker& chunker, bool interned = false)
|
||||
|
|
@ -298,7 +298,7 @@ class String::StringData : protected StringDataImpl
|
|||
StringData* result = new(memory) StringData(data, len, interned);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
bool isShared() const
|
||||
{
|
||||
return ( mRefCount > 1 );
|
||||
|
|
|
|||
|
|
@ -361,7 +361,9 @@ class StringBuilder
|
|||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
return mFormat.formatAppend(fmt, args);
|
||||
const S32 result = mFormat.formatAppend(fmt, args);
|
||||
va_end(args);
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -407,8 +407,15 @@ FileNodeRef ZipFileSystem::resolve(const Path& path)
|
|||
if(mZipNameIsDir)
|
||||
{
|
||||
// Remove the fake root from the name so things can be found
|
||||
#ifdef TORQUE_ZIP_PATH_CASE_INSENSITIVE
|
||||
String lowerFakeRoot = String::ToLower(mFakeRoot);
|
||||
String lowerName = String::ToLower(name);
|
||||
if(lowerName.find(lowerFakeRoot) == 0)
|
||||
name = name.substr(mFakeRoot.length());
|
||||
#else
|
||||
if(name.find(mFakeRoot) == 0)
|
||||
name = name.substr(mFakeRoot.length());
|
||||
name = name.substr(mFakeRoot.length());
|
||||
#endif
|
||||
|
||||
#ifdef TORQUE_DISABLE_FIND_ROOT_WITHIN_ZIP
|
||||
else
|
||||
|
|
@ -480,8 +487,15 @@ FileNodeRef ZipFileSystem::resolveLoose(const Path& path)
|
|||
if(mZipNameIsDir)
|
||||
{
|
||||
// Remove the fake root from the name so things can be found
|
||||
#ifdef TORQUE_ZIP_PATH_CASE_INSENSITIVE
|
||||
String lowerFakeRoot = String::ToLower(mFakeRoot);
|
||||
String lowerName = String::ToLower(name);
|
||||
if(lowerName.find(lowerFakeRoot) == 0)
|
||||
name = name.substr(mFakeRoot.length());
|
||||
#else
|
||||
if(name.find(mFakeRoot) == 0)
|
||||
name = name.substr(mFakeRoot.length());
|
||||
name = name.substr(mFakeRoot.length());
|
||||
#endif
|
||||
|
||||
#ifdef TORQUE_DISABLE_FIND_ROOT_WITHIN_ZIP
|
||||
else
|
||||
|
|
|
|||
|
|
@ -750,10 +750,6 @@ S32 MountSystem::findByPattern( const Path &inBasePath, const String &inFilePatt
|
|||
|
||||
while ( dir->read( &attrs ) )
|
||||
{
|
||||
// skip hidden files
|
||||
if ( attrs.name.c_str()[0] == '.' )
|
||||
continue;
|
||||
|
||||
String name( attrs.name );
|
||||
|
||||
if ( (attrs.flags & FileNode::Directory) && inRecursive )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue