pthread_key_delete(3pthread)


pthread_key_delete -- delete thread-specific data key

Synopsis

   cc [options] -Kthread file
   

#include <pthread.h>

int pthread_key_delete(pthread_key_t *key);

Description

pthread_key_delete deletes a thread-specific data key, which was obtained from a previous call to pthread_key_create. The thread-specific data values associated with key need not be NULL at the time pthread_key_delete is called. It is the responsibility of the application to free any application storage or perform an cleanup actions for data structures related to the deleted key or associated thread-specific data in any threads; this cleanup can be done either before or after pthread_key_delete is called. Any attempt to use key following the call to pthread_key_delete results in undefined behavior.

The pthread_key_delete function is callable from within destructor functions. No destructor functions will be invoked by pthread_key_delete. Any destructor function that may have been associated with key will no longer be called upon thread exit.

The key parameter is the key to be deleted.

A typical use would be for a dynamically linked library to create a private key with pthread_key_create as part of its initialization, use pthread_getspecific and pthread_setspecific while in use, and then call pthread_key_delete before unlinking.

The application should ensure that other thread-specific data functions for key are not called concurrently with pthread_key_delete.

Return values

pthread_key_delete returns zero on success. Otherwise, an error number is returned.

Diagnostics

pthread_key_delete returns the following value if the corresponding condition is detected:

EINVAL
key is invalid.

Standards Compliance

The Single UNIX Specification, Version 2; The Open Group.

References

Intro(3pthread), pthread_getspecific(3pthread), pthread_key_create(3pthread), pthread_setspecific(3pthread), pthread(4)
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004