Checking for memory leaks. Changed the handling of comments about
deleting
This commit is contained in:
parent
1d258a55a4
commit
59c1c16e03
|
@ -155,10 +155,6 @@ static void CheckMemoryLeak_CheckScope( const TOKEN *Tok1, const char varname[]
|
||||||
{
|
{
|
||||||
Alloc = alloc;
|
Alloc = alloc;
|
||||||
alloc_indentlevel = indentlevel;
|
alloc_indentlevel = indentlevel;
|
||||||
|
|
||||||
// Is there a comment such as "var is deleted automaticly"
|
|
||||||
if ( Alloc == New && isdeleted(tok->str) > 0 )
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
45
tokenize.cpp
45
tokenize.cpp
|
@ -287,18 +287,8 @@ void Tokenize(const char FileName[])
|
||||||
// Tokenize - tokenizes input stream
|
// Tokenize - tokenizes input stream
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
struct DeleteComment
|
|
||||||
{
|
|
||||||
unsigned int LineNr;
|
|
||||||
std::string Str;
|
|
||||||
};
|
|
||||||
|
|
||||||
std::list< DeleteComment > DeleteComments;
|
|
||||||
|
|
||||||
void TokenizeCode(std::istream &code, const unsigned int FileIndex)
|
void TokenizeCode(std::istream &code, const unsigned int FileIndex)
|
||||||
{
|
{
|
||||||
DeleteComments.clear();
|
|
||||||
|
|
||||||
// Tokenize the file.
|
// Tokenize the file.
|
||||||
unsigned int lineno = 1;
|
unsigned int lineno = 1;
|
||||||
char CurrentToken[1000] = {0};
|
char CurrentToken[1000] = {0};
|
||||||
|
@ -415,14 +405,25 @@ void TokenizeCode(std::istream &code, const unsigned int FileIndex)
|
||||||
if (ch == '/')
|
if (ch == '/')
|
||||||
{
|
{
|
||||||
std::string comment;
|
std::string comment;
|
||||||
getline( code, comment );
|
getline( code, comment ); // Parse in the whole comment
|
||||||
if ( newstatement && comment.find(" delete")!=std::string::npos )
|
|
||||||
|
// If the comment says something like "fred is deleted" then generate appropriate tokens for that
|
||||||
|
comment = comment + " ";
|
||||||
|
if ( newstatement && comment.find(" deleted ")!=std::string::npos )
|
||||||
{
|
{
|
||||||
DeleteComment dc;
|
// delete
|
||||||
dc.LineNr = lineno;
|
addtoken( "delete", lineno, FileIndex );
|
||||||
dc.Str = comment;
|
|
||||||
DeleteComments.push_back( dc );
|
// fred
|
||||||
|
std::string::size_type pos1 = comment.find_first_not_of(" \t");
|
||||||
|
std::string::size_type pos2 = comment.find(" ", pos1);
|
||||||
|
std::string firstWord = comment.substr( pos1, pos2-pos1 );
|
||||||
|
addtoken( firstWord.c_str(), lineno, FileIndex );
|
||||||
|
|
||||||
|
// ;
|
||||||
|
addtoken( ";", lineno, FileIndex );
|
||||||
}
|
}
|
||||||
|
|
||||||
lineno++;
|
lineno++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1113,15 +1114,3 @@ void DeallocateTokens()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int isdeleted( const char varname[] )
|
|
||||||
{
|
|
||||||
std::list<DeleteComment>::const_iterator it;
|
|
||||||
for ( it = DeleteComments.begin(); it != DeleteComments.end(); it++ )
|
|
||||||
{
|
|
||||||
const DeleteComment &dc = *it;
|
|
||||||
if ( dc.Str.find( varname ) != std::string::npos )
|
|
||||||
return dc.LineNr;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -40,10 +40,6 @@ const TOKEN *gettok(const TOKEN *tok, int index);
|
||||||
const char *getstr(const TOKEN *tok, int index);
|
const char *getstr(const TOKEN *tok, int index);
|
||||||
|
|
||||||
|
|
||||||
// Delete comments such as "fred is deleted automaticly"
|
|
||||||
int isdeleted( const char varname[] );
|
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue