# 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-9d2fd5bffc1f
This commit is contained in:
aramis_acg
2011-04-03 15:12:05 +00:00
parent 45d6647ffe
commit 85cd9be46d
7 changed files with 62 additions and 31 deletions

View File

@@ -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;

View File

@@ -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);
}
// ----------------------------------------------------------------------------------

View File

@@ -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;

View File

@@ -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

View File

@@ -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();
}