From c43038d82edcfd878ff66e3aa7fe247f53876f9b Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Mon, 27 Feb 2012 20:27:09 +0100 Subject: Add more p11-kit cleanup to fix valgrind leak reports * per-thread memory isn't actually a real memory leak, but was still reachable after exit, so clean this up. --- p11-kit/util.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/p11-kit/util.c b/p11-kit/util.c index fd7708a..97a113b 100644 --- a/p11-kit/util.c +++ b/p11-kit/util.c @@ -275,19 +275,30 @@ _p11_library_get_thread_local (void) return local; } +#ifdef __GNUC__ +__attribute__((constructor)) +#endif void _p11_library_init (void) { _p11_debug_init (); + _p11_debug ("initializing library"); _p11_mutex_init (&_p11_mutex); pthread_key_create (&thread_local, free); } +#ifdef __GNUC__ +__attribute__((destructor)) +#endif void _p11_library_uninit (void) { uninit_common (); + /* Some cleanup to pacify valgrind */ + free (pthread_getspecific (thread_local)); + pthread_setspecific (thread_local, NULL); + pthread_key_delete (thread_local); _p11_mutex_uninit (&_p11_mutex); } -- cgit v1.1