Use existing Standards object instead of creating new one

Made const dummy variable static
This commit is contained in:
PKEuS 2013-04-18 04:24:09 -07:00
parent 80cb2a9b20
commit c2664a063e
1 changed files with 5 additions and 9 deletions

View File

@ -66,8 +66,7 @@ void VarInfo::possibleUsageAll(const std::string &functionName)
void CheckLeakAutoVar::leakError(const Token *tok, const std::string &varname, const std::string &type) void CheckLeakAutoVar::leakError(const Token *tok, const std::string &varname, const std::string &type)
{ {
const Standards standards; const CheckMemoryLeak checkmemleak(_tokenizer, _errorLogger, _settings->standards);
CheckMemoryLeak checkmemleak(_tokenizer, _errorLogger, standards);
if (type == "fopen") if (type == "fopen")
checkmemleak.resourceLeakError(tok, varname); checkmemleak.resourceLeakError(tok, varname);
else else
@ -77,18 +76,15 @@ void CheckLeakAutoVar::leakError(const Token *tok, const std::string &varname, c
void CheckLeakAutoVar::mismatchError(const Token *tok, const std::string &varname) void CheckLeakAutoVar::mismatchError(const Token *tok, const std::string &varname)
{ {
const Standards standards; const CheckMemoryLeak c(_tokenizer, _errorLogger, _settings->standards);
CheckMemoryLeak c(_tokenizer, _errorLogger, standards); std::list<const Token *> callstack(1, tok);
std::list<const Token *> callstack;
callstack.push_back(tok);
c.mismatchAllocDealloc(callstack, varname); c.mismatchAllocDealloc(callstack, varname);
//reportError(tok, Severity::error, "newmismatch", "New mismatching allocation and deallocation: " + varname); //reportError(tok, Severity::error, "newmismatch", "New mismatching allocation and deallocation: " + varname);
} }
void CheckLeakAutoVar::deallocUseError(const Token *tok, const std::string &varname) void CheckLeakAutoVar::deallocUseError(const Token *tok, const std::string &varname)
{ {
const Standards standards; const CheckMemoryLeak c(_tokenizer, _errorLogger, _settings->standards);
CheckMemoryLeak c(_tokenizer, _errorLogger, standards);
c.deallocuseError(tok, varname); c.deallocuseError(tok, varname);
//reportError(tok, Severity::error, "newdeallocuse", "Using deallocated pointer " + varname); //reportError(tok, Severity::error, "newdeallocuse", "Using deallocated pointer " + varname);
} }
@ -195,7 +191,7 @@ void CheckLeakAutoVar::check()
VarInfo varInfo; VarInfo varInfo;
// Local variables that are known to be non-zero. // Local variables that are known to be non-zero.
const std::set<unsigned int> notzero; static const std::set<unsigned int> notzero;
checkScope(scope->classStart, &varInfo, notzero); checkScope(scope->classStart, &varInfo, notzero);