From 27003e72b853f82dc969a46290d9268d9342dd42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 30 May 2012 06:36:59 +0200 Subject: [PATCH] Memory leak: minor updates of new leak checking. fixed condition in parseConfiguration. write info message if configuration has been given. --- lib/checkleakautovar.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/checkleakautovar.cpp b/lib/checkleakautovar.cpp index cab57af8f..99eaa84a2 100644 --- a/lib/checkleakautovar.cpp +++ b/lib/checkleakautovar.cpp @@ -85,7 +85,7 @@ void CheckLeakAutoVar::doubleDeallocationError(const Token *tok, const std::stri void CheckLeakAutoVar::configurationInfo(const Token* tok, const std::string &functionName) { - if (_settings->experimental) { + if ((!cfgalloc.empty() || !cfgdealloc.empty()) && _settings->isEnabled("style")) { reportError(tok, Severity::information, "leakconfiguration", @@ -103,7 +103,7 @@ void CheckLeakAutoVar::parseConfigurationFile(const std::string &filename) while (std::getline(fin,line)) { if (line.compare(0,4,"MEM ",0,4) == 0) { std::string f1; - unsigned int type = 1; + enum {ALLOC, DEALLOC} type = ALLOC; std::string::size_type pos1 = line.find_first_not_of(" ", 4U); while (pos1 < line.size()) { const std::string::size_type pos2 = line.find(" ", pos1); @@ -115,10 +115,10 @@ void CheckLeakAutoVar::parseConfigurationFile(const std::string &filename) if (f1.empty()) f1 = f; if (f == ":") - type = 2; - else if (type == 1) + type = DEALLOC; + else if (type == ALLOC) cfgalloc[f] = f1; - else if (type == 1) + else if (type == DEALLOC) cfgdealloc[f] = f1; pos1 = line.find_first_not_of(" ", pos2); }