# some fixes to reduce the size of the binary. Total savings are ~3%. Thanks to Krishty for his efforts in that regard.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@939 67173fc5-114c-0410-ac8e-9d2fd5bffc1fpull/1/head
parent
45d6647ffe
commit
85cd9be46d
|
@ -31,7 +31,7 @@ namespace boost
|
|||
{
|
||||
// XXX add replacement for boost::lexical_cast?
|
||||
|
||||
std::stringstream ss;
|
||||
std::ostringstream ss;
|
||||
ss << in; // note: ss cannot be an rvalue, or the global operator << (const char*) is not called for T == const char*.
|
||||
chunks.push_back( ss.str());
|
||||
return *this;
|
||||
|
|
|
@ -159,47 +159,49 @@ Logger *DefaultLogger::create(const char* name /*= "AssimpLog.txt"*/,
|
|||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
void Logger::debug(const std::string &message) {
|
||||
void Logger::debug(const char* message) {
|
||||
|
||||
// SECURITY FIX: otherwise it's easy to produce overruns ...
|
||||
if (message.length()>MAX_LOG_MESSAGE_LENGTH) {
|
||||
// SECURITY FIX: otherwise it's easy to produce overruns since
|
||||
// sometimes importers will include data from the input file
|
||||
// (i.e. node names) in their messages.
|
||||
if (strlen(message)>MAX_LOG_MESSAGE_LENGTH) {
|
||||
ai_assert(false);
|
||||
return;
|
||||
}
|
||||
return OnDebug(message.c_str());
|
||||
return OnDebug(message);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
void Logger::info(const std::string &message) {
|
||||
void Logger::info(const char* message) {
|
||||
|
||||
// SECURITY FIX: otherwise it's easy to produce overruns ...
|
||||
if (message.length()>MAX_LOG_MESSAGE_LENGTH) {
|
||||
// SECURITY FIX: see above
|
||||
if (strlen(message)>MAX_LOG_MESSAGE_LENGTH) {
|
||||
ai_assert(false);
|
||||
return;
|
||||
}
|
||||
return OnInfo(message.c_str());
|
||||
return OnInfo(message);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
void Logger::warn(const std::string &message) {
|
||||
void Logger::warn(const char* message) {
|
||||
|
||||
// SECURITY FIX: otherwise it's easy to produce overruns ...
|
||||
if (message.length()>MAX_LOG_MESSAGE_LENGTH) {
|
||||
// SECURITY FIX: see above
|
||||
if (strlen(message)>MAX_LOG_MESSAGE_LENGTH) {
|
||||
ai_assert(false);
|
||||
return;
|
||||
}
|
||||
return OnWarn(message.c_str());
|
||||
return OnWarn(message);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
void Logger::error(const std::string &message) {
|
||||
void Logger::error(const char* message) {
|
||||
|
||||
// SECURITY FIX: otherwise it's easy to produce overruns ...
|
||||
if (message.length()>MAX_LOG_MESSAGE_LENGTH) {
|
||||
// SECURITY FIX: see above
|
||||
if (strlen(message)>MAX_LOG_MESSAGE_LENGTH) {
|
||||
ai_assert(false);
|
||||
return;
|
||||
}
|
||||
return OnError(message.c_str());
|
||||
return OnError(message);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
|
|
|
@ -1097,7 +1097,8 @@ void LWOImporter::LoadLWO2Clip(unsigned int length)
|
|||
int16_t offset = GetU2(); mFileBuffer+=4;
|
||||
int16_t start = GetU2(); mFileBuffer+=4;
|
||||
|
||||
std::string s;std::stringstream ss;
|
||||
std::string s;
|
||||
std::ostringstream ss;
|
||||
GetS0(s,head->length);
|
||||
|
||||
head->length -= (unsigned int)s.length()+1;
|
||||
|
|
|
@ -221,7 +221,7 @@ void OgreImporter::ReadSubMesh(SubMesh &theSubMesh, XmlReader *Reader)
|
|||
{
|
||||
//some info logging:
|
||||
unsigned int NumFaces=GetAttribute<int>(Reader, "count");
|
||||
stringstream ss; ss <<"Submesh has " << NumFaces << " Faces.";
|
||||
ostringstream ss; ss <<"Submesh has " << NumFaces << " Faces.";
|
||||
DefaultLogger::get()->debug(ss.str());
|
||||
|
||||
while(XmlRead(Reader) && Reader->getNodeName()==string("face"))
|
||||
|
@ -242,7 +242,7 @@ void OgreImporter::ReadSubMesh(SubMesh &theSubMesh, XmlReader *Reader)
|
|||
{
|
||||
//some info logging:
|
||||
unsigned int NumVertices=GetAttribute<int>(Reader, "vertexcount");
|
||||
stringstream ss; ss<<"VertexCount: "<<NumVertices;
|
||||
ostringstream ss; ss<<"VertexCount: "<<NumVertices;
|
||||
DefaultLogger::get()->debug(ss.str());
|
||||
|
||||
//General Informations about vertices
|
||||
|
|
|
@ -68,7 +68,7 @@ static const std::string Q3BSPExtension = "pk3";
|
|||
// Local function to create a material key name.
|
||||
static void createKey( int id1, int id2, std::string &rKey )
|
||||
{
|
||||
std::stringstream str;
|
||||
std::ostringstream str;
|
||||
str << id1 << "." << id2;
|
||||
rKey = str.str();
|
||||
}
|
||||
|
|
|
@ -94,22 +94,26 @@ public:
|
|||
// ----------------------------------------------------------------------
|
||||
/** @brief Writes a debug message
|
||||
* @param message Debug message*/
|
||||
void debug(const std::string &message);
|
||||
void debug(const char* message);
|
||||
inline void debug(const std::string &message);
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/** @brief Writes a info message
|
||||
* @param message Info message*/
|
||||
void info(const std::string &message);
|
||||
void info(const char* message);
|
||||
inline void info(const std::string &message);
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/** @brief Writes a warning message
|
||||
* @param message Warn message*/
|
||||
void warn(const std::string &message);
|
||||
void warn(const char* message);
|
||||
inline void warn(const std::string &message);
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/** @brief Writes an error message
|
||||
* @param message Error message*/
|
||||
void error(const std::string &message);
|
||||
void error(const char* message);
|
||||
inline void error(const std::string &message);
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/** @brief Set a new log severity.
|
||||
|
@ -227,6 +231,30 @@ inline Logger::LogSeverity Logger::getLogSeverity() const {
|
|||
return m_Severity;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
inline void Logger::debug(const std::string &message)
|
||||
{
|
||||
return debug(message.c_str());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
inline void Logger::error(const std::string &message)
|
||||
{
|
||||
return error(message.c_str());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
inline void Logger::warn(const std::string &message)
|
||||
{
|
||||
return warn(message.c_str());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
inline void Logger::info(const std::string &message)
|
||||
{
|
||||
return info(message.c_str());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
|
||||
} // Namespace Assimp
|
||||
|
|
|
@ -219,7 +219,7 @@ struct aiColor3D
|
|||
*
|
||||
* The character set of an aiString is explicitly defined to be UTF-8. This Unicode
|
||||
* transformation was chosen in the belief that most strings in 3d files are limited
|
||||
* to the ASCII characters, thus the character set needed to be ASCII compatible.
|
||||
* to ASCII, thus the character set needed to be strictly ASCII compatible.
|
||||
*
|
||||
* Most text file loaders provide proper Unicode input file handling, special unicode
|
||||
* characters are correctly transcoded to UTF8 and are kept throughout the libraries'
|
||||
|
@ -275,7 +275,7 @@ struct aiString
|
|||
return;
|
||||
}
|
||||
length = pString.length();
|
||||
::memcpy( data, pString.c_str(), length);
|
||||
memcpy( data, pString.c_str(), length);
|
||||
data[length] = 0;
|
||||
}
|
||||
|
||||
|
@ -286,7 +286,7 @@ struct aiString
|
|||
return;
|
||||
}
|
||||
length = len;
|
||||
::memcpy( data, sz, len);
|
||||
memcpy( data, sz, len);
|
||||
data[len] = 0;
|
||||
}
|
||||
|
||||
|
@ -304,17 +304,17 @@ struct aiString
|
|||
|
||||
/** Comparison operator */
|
||||
bool operator==(const aiString& other) const {
|
||||
return (length == other.length && 0 == strcmp(this->data,other.data));
|
||||
return (length == other.length && 0 == memcmp(data,other.data,length));
|
||||
}
|
||||
|
||||
/** Inverse comparison operator */
|
||||
bool operator!=(const aiString& other) const {
|
||||
return (length != other.length || 0 != ::strcmp(this->data,other.data));
|
||||
return (length != other.length || 0 != memcmp(data,other.data,length));
|
||||
}
|
||||
|
||||
/** Append a string to the string */
|
||||
void Append (const char* app) {
|
||||
const size_t len = ::strlen(app);
|
||||
const size_t len = strlen(app);
|
||||
if (!len) {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue