]> mj.ucw.cz Git - libucw.git/commitdiff
Free thread context structure on thread termination.
authorMartin Mares <mj@ucw.cz>
Mon, 18 Dec 2006 10:52:33 +0000 (11:52 +0100)
committerMartin Mares <mj@ucw.cz>
Mon, 18 Dec 2006 11:33:53 +0000 (12:33 +0100)
lib/threads.c

index 26033e54d8fb49c54b84a8b1d1d50f66b192e03f..f45c8e38a95a36bf8de359e32e526748e2192283 100644 (file)
 static pthread_key_t ucwlib_context_key;
 static pthread_mutex_t ucwlib_master_mutex;
 
 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)
 {
 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);
 }
     die("Cannot create pthread_key: %m");
   pthread_mutex_init(&ucwlib_master_mutex, NULL);
 }