pthread_key_delete() — Delete thread-specific data key

Standards

Standards / Extensions C or C++ Dependencies

Single UNIX Specification, version 3

both

z/OS V1R7
POSIX(ON)

Format

#define _OPEN_THREADS 2
#include <pthread.h>

int pthread_key_delete(pthread_key_t key);

General description

pthread_key_delete() deletes thread-specific data keys created with pthread_key_create(). The thread-specific data values associated with key do not need to be NULL when the key is deleted. The application is responsible for freeing any storage or cleaning up data structures referring to thread-specific data associated with the deleted key in any thread. After key has been deleted, passing it to any function taking a thread-specific data key results in undefined behavior.

pthread_key_delete() can be called from destructor functions. Calling pthread_key_delete() will not cause any destructor functions to be invoked. Any destructor function associated with key when it was created will not be called on thread exit after key has been deleted.

Returned value

If successful, pthread_key_delete() returns 0. Upon failure, pthread_key_delete() returns an error number to indicate the error:
Error Code
Description
EINVAL
The key value is invalid.

Related information