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

Method changeAllocStatusIfRealloc

lib/checkleakautovar.cpp:959–977  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

957
958
959void CheckLeakAutoVarImpl::changeAllocStatusIfRealloc(std::map<int, VarInfo::AllocInfo> &alloctype, const Token *fTok, const Token *retTok) const
960{
961 const Library::AllocFunc* f = mSettings.library.getReallocFuncInfo(fTok);
962 if (f && f->arg == -1 && f->reallocArg > 0 && f->reallocArg <= numberOfArguments(fTok)) {
963 const Token* argTok = getArguments(fTok).at(f->reallocArg - 1);
964 if (alloctype.find(argTok->varId()) != alloctype.end()) {
965 VarInfo::AllocInfo& argAlloc = alloctype[argTok->varId()];
966 if (argAlloc.type != 0 && argAlloc.type != f->groupId)
967 mismatchError(fTok, argAlloc.allocTok, argTok->str());
968 argAlloc.status = VarInfo::REALLOC;
969 argAlloc.allocTok = fTok;
970 }
971 VarInfo::AllocInfo& retAlloc = alloctype[retTok->varId()];
972 retAlloc.type = f->groupId;
973 retAlloc.status = VarInfo::ALLOC;
974 retAlloc.allocTok = fTok;
975 retAlloc.reallocedFromType = argTok->varId();
976 }
977}
978
979
980void CheckLeakAutoVarImpl::changeAllocStatus(VarInfo &varInfo, const VarInfo::AllocInfo& allocation, const Token* tok, const Token* arg)

Callers

nothing calls this directly

Calls 7

numberOfArgumentsFunction · 0.85
getReallocFuncInfoMethod · 0.80
atMethod · 0.80
getArgumentsFunction · 0.70
findMethod · 0.45
endMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected