Fixed bad delete/delete [] invocations and other warnings and errors as suggested by cppcheck

This commit is contained in:
Cirilo Bernardo 2016-04-05 20:32:22 +10:00
parent 18bb852030
commit 20b40aba1c
25 changed files with 27 additions and 40 deletions

View File

@ -567,6 +567,7 @@ bool S3D_FILENAME_RESOLVER::readPathList( void )
int lineno = 0;
S3D_ALIAS al;
al.m_duplicate = false;
size_t idx;
int vnum = 0; // version number
@ -584,7 +585,7 @@ bool S3D_FILENAME_RESOLVER::readPathList( void )
continue;
}
if( 1 == lineno && cfgLine.find( "#V" ) == 0 )
if( 1 == lineno && cfgLine.compare( 0, 2, "#V" ) == 0 )
{
// extract the version number and parse accordingly
if( cfgLine.size() > 2 )

View File

@ -115,7 +115,6 @@ S3D_PLUGIN_MANAGER::~S3D_PLUGIN_MANAGER()
void S3D_PLUGIN_MANAGER::loadPlugins( void )
{
std::list< std::string > pathlist;
std::list< wxString > searchpaths;
std::list< wxString > pluginlist;
wxFileName fn;

View File

@ -83,9 +83,8 @@ private:
std::string lname;
public:
VRML_LOCALE()
VRML_LOCALE() : lname( setlocale( LC_NUMERIC, NULL ) )
{
lname = setlocale( LC_NUMERIC, NULL );
setlocale( LC_NUMERIC, "C" ); // switch the numerics locale to "C"
}

View File

@ -490,8 +490,6 @@ bool SGFACESET::WriteVRML( std::ofstream& aFile, bool aReuseFlag )
return false;
}
std::string tmp;
if( aReuseFlag )
{
if( !m_written )

View File

@ -365,8 +365,6 @@ bool SGSHAPE::WriteVRML( std::ofstream& aFile, bool aReuseFlag )
return false;
}
std::string tmp;
if( aReuseFlag )
{
if( !m_written )

View File

@ -169,7 +169,7 @@ C_OGL_3DMODEL::C_OGL_3DMODEL( const S3DMODEL &a3DModel )
glDisableClientState( GL_NORMAL_ARRAY );
glDisableClientState( GL_VERTEX_ARRAY );
delete pColorRGBA;
delete [] pColorRGBA;
}
}
}// for each mesh

View File

@ -296,7 +296,7 @@ GLuint CLAYERS_OGL_DISP_LISTS::generate_top_or_bot_seg_ends(const CLAYER_TRIANGL
glDisableClientState( GL_VERTEX_ARRAY );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
delete uvArray;
delete [] uvArray;
return listIdx;
}
}

View File

@ -27,6 +27,7 @@
* @brief
*/
#include <cstring>
#include "../common_ogl/openGL_includes.h"
#include "ccamera.h"
#include <wx/log.h>
@ -61,6 +62,7 @@ CCAMERA::CCAMERA( float aRangeScale )
m_viewMatrix_inverse = glm::inverse( m_viewMatrix );
m_scr_nX.clear();
m_scr_nY.clear();
memset( &m_frustum, 0, sizeof( m_frustum ) );
}

View File

@ -119,8 +119,6 @@ bool WRL1BASE::Read( WRLPROC& proc )
return false;
}
std::string glob;
// Note: according to the VRML1 specification, a file may contain
// only one grouping node at the top level. The following code
// supports non-conformant VRML1 files by processing all top level

View File

@ -337,9 +337,6 @@ SGNODE* WRL1FACESET::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp )
}
// 1. create the vertex/normals/colors lists
std::vector< SGPOINT > vlist;
std::vector< SGVECTOR > nlist;
std::vector< SGCOLOR > colorlist;
SGNODE* sgcolor = NULL;
WRL1_BINDING mbind = m_current.matbind;
size_t matSize = matIndex.size();

View File

@ -126,7 +126,6 @@ bool WRL1GROUP::Read( WRLPROC& proc, WRL1BASE* aTopNode )
}
proc.Pop();
std::string glob;
while( true )
{

View File

@ -35,7 +35,7 @@
#include "vrml1_node.h"
bool NAMEREGISTER::AddName( const std::string aName, WRL1NODE* aNode )
bool NAMEREGISTER::AddName( const std::string& aName, WRL1NODE* aNode )
{
if( aName.empty() )
return false;
@ -51,7 +51,7 @@ bool NAMEREGISTER::AddName( const std::string aName, WRL1NODE* aNode )
}
bool NAMEREGISTER::DelName( const std::string aName, WRL1NODE* aNode )
bool NAMEREGISTER::DelName( const std::string& aName, WRL1NODE* aNode )
{
if( aName.empty() )
return false;
@ -68,7 +68,7 @@ bool NAMEREGISTER::DelName( const std::string aName, WRL1NODE* aNode )
}
WRL1NODE* NAMEREGISTER::FindName( const std::string aName )
WRL1NODE* NAMEREGISTER::FindName( const std::string& aName )
{
if( aName.empty() )
return NULL;
@ -390,7 +390,7 @@ const char* WRL1NODE::GetNodeTypeName( WRL1NODES aNodeType ) const
}
WRL1NODES WRL1NODE::getNodeTypeID( const std::string aNodeName )
WRL1NODES WRL1NODE::getNodeTypeID( const std::string& aNodeName )
{
NODEMAP::iterator it = nodenames.find( aNodeName );

View File

@ -49,9 +49,9 @@ private:
std::map< std::string, WRL1NODE* > reg;
public:
bool AddName( const std::string aName, WRL1NODE* aNode );
bool DelName( const std::string aName, WRL1NODE* aNode );
WRL1NODE* FindName( const std::string aName );
bool AddName( const std::string& aName, WRL1NODE* aNode );
bool DelName( const std::string& aName, WRL1NODE* aNode );
WRL1NODE* FindName( const std::string& aName );
};
@ -150,7 +150,7 @@ public:
* returns the ID based on the given aNodeName or WRL1_INVALID (WRL1_END)
* if no such node name exists
*/
WRL1NODES getNodeTypeID( const std::string aNodeName );
WRL1NODES getNodeTypeID( const std::string& aNodeName );
/**
* Function unlinkChild

View File

@ -120,7 +120,6 @@ bool WRL1SEPARATOR::Read( WRLPROC& proc, WRL1BASE* aTopNode )
}
proc.Pop();
std::string glob;
while( true )
{

View File

@ -118,7 +118,7 @@ SGNODE* WRL2BASE::GetInlineData( const std::string& aName )
wxString tname;
if( aName.find( "file://", 0, 7 ) == 0 )
if( aName.compare( 0, 7, "file://" ) == 0 )
{
if( aName.length() <= 7 )
return NULL;

View File

@ -33,6 +33,7 @@
WRL2INLINE::WRL2INLINE() : WRL2NODE()
{
m_VRML2Base = NULL;
m_Type = WRL2_INLINE;
m_Parent = NULL;
@ -42,6 +43,7 @@ WRL2INLINE::WRL2INLINE() : WRL2NODE()
WRL2INLINE::WRL2INLINE( WRL2NODE* aParent ) : WRL2NODE()
{
m_VRML2Base = NULL;
m_Type = WRL2_INLINE;
m_Parent = aParent;

View File

@ -307,7 +307,7 @@ const char* WRL2NODE::GetNodeTypeName( WRL2NODES aNodeType ) const
}
WRL2NODES WRL2NODE::getNodeTypeID( const std::string aNodeName )
WRL2NODES WRL2NODE::getNodeTypeID( const std::string& aNodeName )
{
NODEMAP::iterator it = nodenames.find( aNodeName );

View File

@ -76,7 +76,7 @@ public:
* returns the ID based on the given aNodeName or WRL2_INVALID (WRL2_END)
* if no such node name exists
*/
WRL2NODES getNodeTypeID( const std::string aNodeName );
WRL2NODES getNodeTypeID( const std::string& aNodeName );
/**
* Function unlinkChild

View File

@ -291,7 +291,6 @@ bool WRL2SWITCH::readChildren( WRLPROC& proc, WRL2BASE* aTopNode )
}
proc.Pop();
std::string glob;
while( true )
{

View File

@ -402,7 +402,6 @@ bool WRL2TRANSFORM::readChildren( WRLPROC& proc, WRL2BASE* aTopNode )
}
proc.Pop();
std::string glob;
while( true )
{

View File

@ -77,9 +77,7 @@ WRLPROC::WRLPROC( LINE_READER* aLineReader )
if( m_eof )
return;
m_buf = m_buf.substr( 0, 16 );
if( m_buf.find( "#VRML V1.0 ascii" ) == 0 )
if( m_buf.compare( 0, 16, "#VRML V1.0 ascii" ) == 0 )
{
m_fileVersion = VRML_V1;
// nothing < 0x20, and no:
@ -92,7 +90,7 @@ WRLPROC::WRLPROC( LINE_READER* aLineReader )
return;
}
if( m_buf.find( "#VRML V2.0 utf8" ) == 0 )
if( m_buf.compare( 0, 15, "#VRML V2.0 utf8" ) == 0 )
{
m_fileVersion = VRML_V2;
// nothing < 0x20, and no:
@ -260,7 +258,7 @@ bool WRLPROC::ReadGlob( std::string& aGlob )
size_t ssize = m_buf.size();
while( m_buf[m_bufpos] > 0x20 && m_bufpos < ssize )
while( m_bufpos < ssize && m_buf[m_bufpos] > 0x20 )
{
if( ',' == m_buf[m_bufpos] )
{
@ -304,7 +302,7 @@ bool WRLPROC::ReadName( std::string& aName )
size_t ssize = m_buf.size();
while( m_buf[m_bufpos] > 0x20 && m_bufpos < ssize )
while( m_bufpos < ssize && m_buf[m_bufpos] > 0x20 )
{
if( '[' == m_buf[m_bufpos] || '{' == m_buf[m_bufpos]
|| '.' == m_buf[m_bufpos] || '#' == m_buf[m_bufpos]

View File

@ -62,7 +62,7 @@ SCENEGRAPH* X3DPARSER::Load( const wxString& aFileName )
for( NODE_LIST::iterator node_it = children.begin();
node_it != children.end();
node_it++ )
++node_it )
{
wxXmlNode* node = *node_it;
wxString name = node->GetName();

View File

@ -80,6 +80,7 @@ X3DNODE* X3D_DICT::FindName( const wxString& aName )
X3DNODE::X3DNODE()
{
m_Type = X3D_INVALID;
m_Parent = NULL;
m_sgNode = NULL;
m_Dict = NULL;

View File

@ -202,7 +202,6 @@ bool KICAD_PLUGIN_LDR_3D::Open( const wxString& aFullFileName )
ostr << errmsg.ToUTF8() << "\n";
ostr << "'" << aFullFileName.ToUTF8() << "'";
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
fail = true;
}
else
{

View File

@ -169,7 +169,6 @@ bool KICAD_PLUGIN_LDR::open( const wxString& aFullFileName, const char* aPluginC
ostr << errmsg.ToUTF8() << "\n";
ostr << "'" << aFullFileName.ToUTF8() << "'";
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
fail = true;
}
else
{
@ -260,7 +259,7 @@ bool KICAD_PLUGIN_LDR::open( const wxString& aFullFileName, const char* aPluginC
ostr << " * [INFO] opened plugin " << m_fileName.ToUTF8();
char const* cp = m_getPluginName();
if( !cp )
if( NULL != cp )
ostr << " * [INFO] plugin name: '" << cp << "'\n";
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );