pthread_key_delete

Destroys the specified key.

Library:LibC
Classification:POSIX
Service:Threads

Syntax

  #include <pthread.h> 
   
  int   pthread_key_delete (
     pthread_key_t   key);
  

Parameters

key

(IN) Specifies the key to destroy.

Return Values

If successful, returns 0; otherwise, returns a nonzero error code:

Decimal

Constant

Description

9

EINVAL

The specified key has not been allocated.

Remarks

The pthread_key_delete functions frees up a previously allocated key, which results in revoking the slot number that was reserved in the CSD array. Once a key is destroyed, threads cannot manipulate the value that was associated with the key.

WARNING:When a key is deleted, any associated destructor is not called. You must clean up any values that threads might have associated with the key before that key is deleted.

Usually, you do not need to destroy a key. When a thread exits, the destructor is automatically called to destroy key values associated with that thread. When the last thread of your application exits, the destructor is called for the last time and the key is automatically destroyed.

See Also