disabling leak detective at runtime by setting LEAK_DETECTIVE_DISABLE env var

This commit is contained in:
Martin Willi
2007-06-08 07:21:03 +00:00
parent b9659a50dc
commit 9cc7a29786
+11
View File
@@ -409,18 +409,24 @@ void *realloc_hook(void *old, size_t bytes, const void *caller)
* Setup leak detective * Setup leak detective
*/ */
void __attribute__ ((constructor)) leak_detective_init() void __attribute__ ((constructor)) leak_detective_init()
{
if (getenv("LEAK_DETECTIVE_DISABLE") == NULL)
{ {
install_hooks(); install_hooks();
} }
}
/** /**
* Clean up leak detective * Clean up leak detective
*/ */
void __attribute__ ((destructor)) leak_detective_cleanup() void __attribute__ ((destructor)) leak_detective_cleanup()
{
if (getenv("LEAK_DETECTIVE_DISABLE") == NULL)
{ {
uninstall_hooks(); uninstall_hooks();
report_leaks(); report_leaks();
} }
}
/** /**
* Log memory allocation statistics * Log memory allocation statistics
@@ -431,6 +437,11 @@ void leak_detective_status(FILE *stream)
size_t bytes = 0; size_t bytes = 0;
memory_header_t *hdr = &first_header; memory_header_t *hdr = &first_header;
if (getenv("LEAK_DETECTIVE_DISABLE"))
{
return;
}
pthread_mutex_lock(&mutex); pthread_mutex_lock(&mutex);
while ((hdr = hdr->next)) while ((hdr = hdr->next))
{ {