From c2664a063eca851e9d4a8f360363fdf220ede6c6 Mon Sep 17 00:00:00 2001 From: PKEuS Date: Thu, 18 Apr 2013 04:24:09 -0700 Subject: [PATCH] Use existing Standards object instead of creating new one Made const dummy variable static --- lib/checkleakautovar.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/checkleakautovar.cpp b/lib/checkleakautovar.cpp index 73447da8d..89b44108e 100644 --- a/lib/checkleakautovar.cpp +++ b/lib/checkleakautovar.cpp @@ -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) { - const Standards standards; - CheckMemoryLeak checkmemleak(_tokenizer, _errorLogger, standards); + const CheckMemoryLeak checkmemleak(_tokenizer, _errorLogger, _settings->standards); if (type == "fopen") checkmemleak.resourceLeakError(tok, varname); 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) { - const Standards standards; - CheckMemoryLeak c(_tokenizer, _errorLogger, standards); - std::list callstack; - callstack.push_back(tok); + const CheckMemoryLeak c(_tokenizer, _errorLogger, _settings->standards); + std::list callstack(1, tok); c.mismatchAllocDealloc(callstack, varname); //reportError(tok, Severity::error, "newmismatch", "New mismatching allocation and deallocation: " + varname); } void CheckLeakAutoVar::deallocUseError(const Token *tok, const std::string &varname) { - const Standards standards; - CheckMemoryLeak c(_tokenizer, _errorLogger, standards); + const CheckMemoryLeak c(_tokenizer, _errorLogger, _settings->standards); c.deallocuseError(tok, varname); //reportError(tok, Severity::error, "newdeallocuse", "Using deallocated pointer " + varname); } @@ -195,7 +191,7 @@ void CheckLeakAutoVar::check() VarInfo varInfo; // Local variables that are known to be non-zero. - const std::set notzero; + static const std::set notzero; checkScope(scope->classStart, &varInfo, notzero);