Merge branch 'master' into coverity_scan

pull/1007/head
Kim Kulling 2016-09-04 20:41:13 +02:00
commit 1f22e33b96
6 changed files with 52 additions and 46 deletions

View File

@ -123,8 +123,7 @@ namespace Blender {
struct ObjectCompare {
bool operator() (const Object* left, const Object* right) const {
printf( "left: %s, right: %s\n", left->id.name, right->id.name );
return ::strncmp(left->id.name, right->id.name, strlen( left->id.name ) ) == 0;
return ::strncmp(left->id.name, right->id.name, strlen( left->id.name ) ) == -1;
}
};
@ -145,8 +144,7 @@ namespace Blender {
struct ObjectCompare {
bool operator() (const Object* left, const Object* right) const {
printf( "left: %s, right: %s\n", left->id.name, right->id.name );
return ::strncmp( left->id.name, right->id.name, strlen( left->id.name ) ) == 0;
return ::strncmp( left->id.name, right->id.name, strlen( left->id.name ) ) == -1;
}
};

View File

@ -437,7 +437,7 @@ void ComputeUVMappingProcess::Execute( aiScene* pScene)
}
}
unsigned int idx;
unsigned int idx( 99999999 );
// Check whether we have this mapping mode already
std::list<MappingInfo>::iterator it = std::find (mappingStack.begin(),mappingStack.end(), info);

View File

@ -715,14 +715,14 @@ void FindAdjacentContours(ContourVector::iterator current, const ContourVector&
const Contour& mcontour = (*it).contour;
for (size_t n = 0; n < ncontour.size(); ++n) {
const IfcVector2& n0 = ncontour[n];
const IfcVector2& n1 = ncontour[(n+1) % ncontour.size()];
const IfcVector2 n0 = ncontour[n];
const IfcVector2 n1 = ncontour[(n+1) % ncontour.size()];
for (size_t m = 0, mend = (is_me ? n : mcontour.size()); m < mend; ++m) {
ai_assert(&mcontour != &ncontour || m < n);
const IfcVector2& m0 = mcontour[m];
const IfcVector2& m1 = mcontour[(m+1) % mcontour.size()];
const IfcVector2 m0 = mcontour[m];
const IfcVector2 m1 = mcontour[(m+1) % mcontour.size()];
IfcVector2 isect0, isect1;
if (IntersectingLineSegments(n0,n1, m0, m1, isect0, isect1)) {

View File

@ -116,6 +116,16 @@ const aiImporterDesc* IRRMeshImporter::GetInfo () const
return &desc;
}
static void releaseMaterial( aiMaterial **mat ) {
delete mat;
*mat = nullptr;
}
static void releaseMesh( aiMesh **mesh ) {
delete mesh;
*mesh = nullptr;
}
// ------------------------------------------------------------------------------------------------
// Imports the given file into the given scene structure.
void IRRMeshImporter::InternReadFile( const std::string& pFile,
@ -135,7 +145,7 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
std::vector<aiMaterial*> materials;
std::vector<aiMesh*> meshes;
materials.reserve (5);
meshes.reserve (5);
meshes.reserve(5);
// temporary data - current mesh buffer
aiMaterial* curMat = NULL;
@ -159,11 +169,10 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
if (!ASSIMP_stricmp(reader->getNodeName(),"buffer") && (curMat || curMesh)) {
// end of previous buffer. A material and a mesh should be there
if ( !curMat || !curMesh) {
DefaultLogger::get()->error("IRRMESH: A buffer must contain a mesh and a material");
delete curMat;
delete curMesh;
}
else {
DefaultLogger::get()->error("IRRMESH: A buffer must contain a mesh and a material");
releaseMaterial( &curMat );
releaseMesh( &curMesh );
} else {
materials.push_back(curMat);
meshes.push_back(curMesh);
}
@ -183,7 +192,7 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
if (!ASSIMP_stricmp(reader->getNodeName(),"material")) {
if (curMat) {
DefaultLogger::get()->warn("IRRMESH: Only one material description per buffer, please");
delete curMat;curMat = NULL;
releaseMaterial( &curMat );
}
curMat = ParseMaterial(curMatFlags);
}
@ -195,17 +204,16 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
// This is possible ... remove the mesh from the list and skip further reading
DefaultLogger::get()->warn("IRRMESH: Found mesh with zero vertices");
delete curMat;curMat = NULL;
curMesh = NULL;
releaseMaterial( &curMat );
releaseMesh( &curMesh );
textMeaning = 0;
continue;
}
curVertices.reserve (num);
curNormals.reserve (num);
curColors.reserve (num);
curUVs.reserve (num);
curVertices.reserve(num);
curNormals.reserve(num);
curColors.reserve(num);
curUVs.reserve(num);
// Determine the file format
const char* t = reader->getAttributeValueSafe("type");
@ -240,7 +248,7 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
vertexFormat = 2;
}
else if (ASSIMP_stricmp("standard", t)) {
delete curMat;
releaseMaterial( &curMat );
DefaultLogger::get()->warn("IRRMESH: Unknown vertex format");
}
else vertexFormat = 0;
@ -248,7 +256,7 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
}
else if (!ASSIMP_stricmp(reader->getNodeName(),"indices")) {
if (curVertices.empty() && curMat) {
delete curMat;
releaseMaterial( &curMat );
throw DeadlyImportError("IRRMESH: indices must come after vertices");
}
@ -264,10 +272,10 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
DefaultLogger::get()->warn("IRRMESH: Found mesh with zero indices");
// mesh - away
delete curMesh; curMesh = NULL;
releaseMesh( &curMesh );
// material - away
delete curMat;curMat = NULL;
releaseMaterial( &curMat );
textMeaning = 0;
continue;
@ -469,7 +477,6 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
break;
default:
// GCC complains here ...
break;
@ -480,8 +487,8 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
if (curMat || curMesh) {
if ( !curMat || !curMesh) {
DefaultLogger::get()->error("IRRMESH: A buffer must contain a mesh and a material");
delete curMat;
delete curMesh;
releaseMaterial( &curMat );
releaseMesh( &curMesh );
}
else {
materials.push_back(curMat);

View File

@ -74,20 +74,22 @@ static const aiImporterDesc desc = {
// ------------------------------------------------------------------------------------------------
// Constructor to be privately used by Importer
SMDImporter::SMDImporter()
: configFrameID(),
mBuffer(),
pScene(),
iFileSize(),
iSmallestFrame(),
dLengthOfAnim(),
bHasUVs(),
iLineNumber()
{}
: configFrameID(),
mBuffer(),
pScene( nullptr ),
iFileSize( 0 ),
iSmallestFrame( -1 ),
dLengthOfAnim( 0.0 ),
bHasUVs(false ),
iLineNumber(-1) {
// empty
}
// ------------------------------------------------------------------------------------------------
// Destructor, private as well
SMDImporter::~SMDImporter()
{}
SMDImporter::~SMDImporter() {
// empty
}
// ------------------------------------------------------------------------------------------------
// Returns whether the class can handle the format of the given file.
@ -133,9 +135,8 @@ void SMDImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOS
// Allocate storage and copy the contents of the file to a memory buffer
this->pScene = pScene;
std::vector<char> buff(iFileSize+1);
TextFileToBuffer(file.get(),buff);
mBuffer = &buff[0];
mBuffer.resize( iFileSize + 1 );
TextFileToBuffer(file.get(), mBuffer );
iSmallestFrame = (1 << 31);
bHasUVs = true;
@ -694,7 +695,7 @@ void SMDImporter::CreateOutputMaterials()
// Parse the file
void SMDImporter::ParseFile()
{
const char* szCurrent = mBuffer;
const char* szCurrent = &mBuffer[0];
// read line per line ...
for ( ;; )

View File

@ -372,7 +372,7 @@ private:
unsigned int configFrameID;
/** Buffer to hold the loaded file */
const char* mBuffer;
std::vector<char> mBuffer;
/** Output scene to be filled
*/