[PATCH] Add more p11-kit cleanup to fix valgrind leak reports
Stef Walter
stefw at gnome.org
Mon Feb 27 11:27:09 PST 2012
* per-thread memory isn't actually a real memory leak, but was
still reachable after exit, so clean this up.
---
p11-kit/util.c | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/p11-kit/util.c b/p11-kit/util.c
index c04b636..521a8e9 100644
--- a/p11-kit/util.c
+++ b/p11-kit/util.c
@@ -266,17 +266,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)
{
+ _p11_debug ("uninitializing library");
+
+ /* 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);
}
--
1.7.7.6
--------------030200000300090005010300--
More information about the p11-glue
mailing list