From 7469a39867d251cf81e03a25922d29a49af3fee6 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Mon, 18 Dec 2006 11:52:33 +0100 Subject: [PATCH] Free thread context structure on thread termination. --- lib/threads.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/threads.c b/lib/threads.c index 26033e54..f45c8e38 100644 --- a/lib/threads.c +++ b/lib/threads.c @@ -17,10 +17,16 @@ static pthread_key_t ucwlib_context_key; static pthread_mutex_t ucwlib_master_mutex; +static void +ucwlib_free_thread_context(void *p) +{ + xfree(p); +} + static void CONSTRUCTOR ucwlib_threads_init(void) { - if (pthread_key_create(&ucwlib_context_key, NULL) < 0) + if (pthread_key_create(&ucwlib_context_key, ucwlib_free_thread_context) < 0) die("Cannot create pthread_key: %m"); pthread_mutex_init(&ucwlib_master_mutex, NULL); } -- 2.39.5