MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / check

Method check

lib/checkmemoryleak.cpp:511–533  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

509//---------------------------------------------------------------------------
510
511void CheckMemoryLeakInClassImpl::check()
512{
513 logChecker("CheckMemoryLeakInClass::check");
514
515 const SymbolDatabase *symbolDatabase = mTokenizer->getSymbolDatabase();
516
517 // only check classes and structures
518 for (const Scope * scope : symbolDatabase->classAndStructScopes) {
519 for (const Variable &var : scope->varlist) {
520 if (!var.isStatic() && (var.isPointer() || var.isPointerArray())) {
521 // allocation but no deallocation of private variables in public function..
522 const Token *tok = var.typeStartToken();
523 // Either it is of standard type or a non-derived type
524 if (tok->isStandardType() || (var.type() && var.type()->derivedFrom.empty())) {
525 if (var.isPrivate())
526 checkPublicFunctions(scope, var.nameToken());
527
528 variable(scope, var.nameToken());
529 }
530 }
531 }
532 }
533}
534
535
536void CheckMemoryLeakInClassImpl::variable(const Scope *scope, const Token *tokVarname)

Callers 1

runChecksMethod · 0.45

Calls 7

variableFunction · 0.85
isPointerArrayMethod · 0.80
typeMethod · 0.80
scopeMethod · 0.80
isStandardTypeMethod · 0.45
emptyMethod · 0.45
nameTokenMethod · 0.45

Tested by

no test coverage detected