disabling leak detective at runtime by setting LEAK_DETECTIVE_DISABLE env var
This commit is contained in:
@@ -409,18 +409,24 @@ void *realloc_hook(void *old, size_t bytes, const void *caller)
|
||||
* Setup leak detective
|
||||
*/
|
||||
void __attribute__ ((constructor)) leak_detective_init()
|
||||
{
|
||||
if (getenv("LEAK_DETECTIVE_DISABLE") == NULL)
|
||||
{
|
||||
install_hooks();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up leak detective
|
||||
*/
|
||||
void __attribute__ ((destructor)) leak_detective_cleanup()
|
||||
{
|
||||
if (getenv("LEAK_DETECTIVE_DISABLE") == NULL)
|
||||
{
|
||||
uninstall_hooks();
|
||||
report_leaks();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log memory allocation statistics
|
||||
@@ -431,6 +437,11 @@ void leak_detective_status(FILE *stream)
|
||||
size_t bytes = 0;
|
||||
memory_header_t *hdr = &first_header;
|
||||
|
||||
if (getenv("LEAK_DETECTIVE_DISABLE"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&mutex);
|
||||
while ((hdr = hdr->next))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user