Use pthread_key_delete(3T) to destroy an existing thread-specific data key. Any memory associated with the key can be freed because the key has been invalidated and will return an error if ever referenced. There is no comparable function in Solaris threads.
Prototype: int pthread_key_delete(pthread_key_t key);
#include <pthread.h> pthread_key_t key; int ret; /* key previously created */ ret = pthread_key_delete(key);
Once a key has been deleted, any reference to it with the pthread_setspecific() or pthread_getspecific() call results in the EINVAL error.
It is the responsibility of the programmer to free any thread-specific resources before calling the delete function. This function does not invoke any of the destructors.
Returns zero after completing successfully. Any other returned value indicates that an error occurred. When the following condition occurs, pthread_key_create() fails and returns the corresponding value.