From f37e8252a358e33e3a11701c99e5e63d20ce784f Mon Sep 17 00:00:00 2001 From: Martin Willi Date: Fri, 29 Apr 2011 14:52:32 +0200 Subject: [PATCH] Make leak detective public --- src/libstrongswan/library.c | 20 +++++--------------- src/libstrongswan/library.h | 5 +++-- src/libstrongswan/utils/leak_detective.c | 1 - 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/libstrongswan/library.c b/src/libstrongswan/library.c index b7e75ae..9fc99e3 100644 --- a/src/libstrongswan/library.c +++ b/src/libstrongswan/library.c @@ -40,13 +40,6 @@ struct private_library_t { * public functions */ library_t public; - -#ifdef LEAK_DETECTIVE - /** - * Memory leak detective, if enabled - */ - leak_detective_t *detective; -#endif /* LEAK_DETECTIVE */ }; /** @@ -81,13 +74,11 @@ void library_deinit() this->public.integrity->destroy(this->public.integrity); } -#ifdef LEAK_DETECTIVE - if (this->detective) + if (lib->leak_detective) { - this->detective->report(this->detective, detailed); - this->detective->destroy(this->detective); + lib->leak_detective->report(lib->leak_detective, detailed); + lib->leak_detective->destroy(lib->leak_detective); } -#endif /* LEAK_DETECTIVE */ threads_deinit(); @@ -106,10 +97,9 @@ bool library_init(char *settings) threads_init(); - lib->leak_detective = FALSE; - + lib->leak_detective = NULL; #ifdef LEAK_DETECTIVE - this->detective = leak_detective_create(); + lib->leak_detective = leak_detective_create(); #endif /* LEAK_DETECTIVE */ pfh = printf_hook_create(); diff --git a/src/libstrongswan/library.h b/src/libstrongswan/library.h index 034ff10..b1c5778 100644 --- a/src/libstrongswan/library.h +++ b/src/libstrongswan/library.h @@ -78,6 +78,7 @@ #include "credentials/credential_factory.h" #include "credentials/credential_manager.h" #include "credentials/cred_encoding.h" +#include "utils/leak_detective.h" typedef struct library_t library_t; @@ -147,9 +148,9 @@ struct library_t { integrity_checker_t *integrity; /** - * is leak detective running? + * Leak detective, if built and enabled */ - bool leak_detective; + leak_detective_t *leak_detective; }; /** diff --git a/src/libstrongswan/utils/leak_detective.c b/src/libstrongswan/utils/leak_detective.c index a295ce4..e770e12 100644 --- a/src/libstrongswan/utils/leak_detective.c +++ b/src/libstrongswan/utils/leak_detective.c @@ -526,7 +526,6 @@ leak_detective_t *leak_detective_create() fprintf(stderr, "setting CPU affinity failed: %m"); } - lib->leak_detective = TRUE; install_hooks(); } return &this->public; -- 2.7.4