backtrace->contains_function takes multiple names, speeding up whitelist check drastically

This commit is contained in:
Martin Willi
2011-01-17 18:19:44 +01:00
parent ec8426a349
commit b94feb4b05
3 changed files with 16 additions and 26 deletions
+2 -17
View File
@@ -232,22 +232,6 @@ char *whitelist[] = {
"gpg_err_init",
};
/**
* check if a stack frame contains functions listed above
*/
static bool is_whitelisted(backtrace_t *backtrace)
{
int i;
for (i = 0; i < sizeof(whitelist)/sizeof(char*); i++)
{
if (backtrace->contains_function(backtrace, whitelist[i]))
{
return TRUE;
}
}
return FALSE;
}
/**
* Report leaks at library destruction
*/
@@ -260,7 +244,8 @@ static void report(private_leak_detective_t *this, bool detailed)
for (hdr = first_header.next; hdr != NULL; hdr = hdr->next)
{
if (is_whitelisted(hdr->backtrace))
if (hdr->backtrace->contains_function(hdr->backtrace,
whitelist, countof(whitelist)))
{
whitelisted++;
}