Library: move Library::alloc and Library::dealloc from header to cpp file and use the functionName utility function

This commit is contained in:
Daniel Marjamäki 2015-08-10 18:36:09 +02:00
parent 30c7b58e4c
commit a70c57daa2
2 changed files with 19 additions and 8 deletions

View File

@ -679,6 +679,21 @@ static std::string functionName(const Token *ftok)
return ret;
}
/** get allocation id for function */
int Library::alloc(const Token *tok) const
{
const std::string funcname = functionName(tok);
return isNotLibraryFunction(tok) && argumentChecks.find(funcname) != argumentChecks.end() ? 0 : getid(_alloc, funcname);
}
/** get deallocation id for function */
int Library::dealloc(const Token *tok) const
{
const std::string funcname = functionName(tok);
return isNotLibraryFunction(tok) && argumentChecks.find(funcname) != argumentChecks.end() ? 0 : getid(_dealloc, funcname);
}
const Library::ArgumentChecks * Library::getarg(const Token *ftok, int argnr) const
{
if (isNotLibraryFunction(ftok))

View File

@ -63,22 +63,18 @@ public:
/** this is primarily meant for unit tests. it only returns true/false */
bool loadxmldata(const char xmldata[], std::size_t len);
/** get allocation id for function by name */
/** get allocation id for function by name (deprecated, use other alloc) */
int alloc(const char name[]) const {
return getid(_alloc, name);
}
/** get allocation id for function */
int alloc(const Token *tok) const {
return isNotLibraryFunction(tok) && argumentChecks.find(tok->str()) != argumentChecks.end() ? 0 : getid(_alloc, tok->str());
}
int alloc(const Token *tok) const;
/** get deallocation id for function */
int dealloc(const Token *tok) const {
return isNotLibraryFunction(tok) && argumentChecks.find(tok->str()) != argumentChecks.end() ? 0 : getid(_dealloc, tok->str());
}
int dealloc(const Token *tok) const;
/** get deallocation id for function by name */
/** get deallocation id for function by name (deprecated, use other alloc) */
int dealloc(const char name[]) const {
return getid(_dealloc, name);
}