leak-detective: Register OS X specific hooks just once

If we initialize libstrongswan more than once in the same process, we may
not register the hooks twice.
This commit is contained in:
Martin Willi 2013-11-06 10:09:04 +01:00
parent f192526c3f
commit ef6d78d6ef
1 changed files with 7 additions and 0 deletions

View File

@ -333,9 +333,16 @@ HOOK(size_t, size, const void *ptr)
*/
static bool register_hooks()
{
static bool once = FALSE;
malloc_zone_t *zone;
void *page;
if (once)
{
return TRUE;
}
once = TRUE;
zone = malloc_default_zone();
if (zone->version != MALLOC_ZONE_VERSION)
{