Replaced C function bsearch with std::binary_search

This commit is contained in:
PKEuS 2013-04-03 01:35:08 -07:00
parent 51685f24c5
commit c5d636c074
1 changed files with 3 additions and 15 deletions

View File

@ -23,8 +23,6 @@
#include "tokenize.h"
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <set>
#include <stack>
@ -92,16 +90,6 @@ static const char * const call_func_white_list[] = {
, "vscanf", "vsnprintf", "vsprintf", "vsscanf", "while", "wordexp","write", "writev"
};
extern "C"
{
int call_func_white_list_compare(const void *a, const void *b);
int call_func_white_list_compare(const void *a, const void *b)
{
return std::strcmp((const char *)a, *(const char * const *)b);
}
}
//---------------------------------------------------------------------------
bool CheckMemoryLeak::isclass(const Token *tok, unsigned int varid) const
@ -584,9 +572,9 @@ bool CheckMemoryLeakInFunction::notvar(const Token *tok, unsigned int varid, boo
bool CheckMemoryLeakInFunction::test_white_list(const std::string &funcname)
{
return (std::bsearch(funcname.c_str(), call_func_white_list,
sizeof(call_func_white_list) / sizeof(call_func_white_list[0]),
sizeof(call_func_white_list[0]), call_func_white_list_compare) != NULL);
return (std::binary_search(call_func_white_list,
call_func_white_list+sizeof(call_func_white_list) / sizeof(call_func_white_list[0]),
funcname));
}
const char * CheckMemoryLeakInFunction::call_func(const Token *tok, std::list<const Token *> callstack, const unsigned int varid, AllocType &alloctype, AllocType &dealloctype, bool &allocpar, unsigned int sz)