--- libxml2-2.6.27/threads.c	2006-06-26 14:16:03.000000000 +0200
+++ src/threads.c	2008-12-09 16:47:37.000000000 +0100
@@ -63,6 +63,8 @@
 extern int pthread_key_create (pthread_key_t *__key,
                                void (*__destr_function) (void *))
 	   __attribute((weak));
+extern int pthread_key_delete (pthread_key_t __key)
+	   __attribute((weak));
 extern int pthread_mutex_init ()
 	   __attribute((weak));
 extern int pthread_mutex_destroy ()
@@ -79,6 +81,8 @@
 	   __attribute((weak));
 extern int pthread_key_create ()
 	   __attribute((weak));
+extern int pthread_key_delete ()
+	   __attribute((weak));
 extern int pthread_cond_signal ()
 	   __attribute((weak));
 #endif
@@ -718,6 +722,7 @@
 	    (pthread_getspecific != NULL) &&
 	    (pthread_setspecific != NULL) &&
 	    (pthread_key_create != NULL) &&
+	    (pthread_key_delete != NULL) &&
 	    (pthread_mutex_init != NULL) &&
 	    (pthread_mutex_destroy != NULL) &&
 	    (pthread_mutex_lock != NULL) &&
@@ -726,6 +731,7 @@
 	    (pthread_equal != NULL) &&
 	    (pthread_self != NULL) &&
 	    (pthread_key_create != NULL) &&
+	    (pthread_key_delete != NULL) &&
 	    (pthread_cond_signal != NULL)) {
 	    libxml_is_threaded = 1;
 /* fprintf(stderr, "Running multithreaded\n"); */
@@ -766,6 +772,8 @@
 	globalkey = TLS_OUT_OF_INDEXES;
     }
     DeleteCriticalSection(&cleanup_helpers_cs);
+#elif defined HAVE_PTHREAD_H
+	pthread_key_delete(globalkey);
 #endif
 }
 
