From ca4015f905148ba0f796c8ebcc41af2bf1566133 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 6 Mar 2011 09:42:16 +0100 Subject: [PATCH] CheckMemoryLeak: Refactoring the code --- lib/checkmemoryleak.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index 4dd122d1a..cbb7bd954 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -1588,17 +1588,19 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::listlink(),") (")) { - int tokIdx = matchFirst ? 2 : 3; + const Token *tok2 = tok->next(); + if (tok2->str() == "*") + tok2 = tok2->next(); + tok2 = tok2->next(); - while (Token::Match(tok->tokAt(tokIdx), ". %var%")) - tokIdx += 2; + while (Token::Match(tok2, ". %var%")) + tok2 = tok2->tokAt(2); - if (Token::simpleMatch(tok->tokAt(tokIdx), ") (")) + if (Token::simpleMatch(tok2, ") (")) { - for (const Token *tok2 = tok->tokAt(tokIdx + 2); tok2; tok2 = tok2->next()) + for (; tok2; tok2 = tok2->next()) { if (Token::Match(tok2, "[;{]")) break;