Multithreaded Programming Guide

Return Values

pthread_setspecific() returns zero after completing successfully. Any other returned value indicates that an error occurred. When any of the following conditions occur, pthread_setspecific() fails and returns the corresponding value.


ENOMEM

Not enough virtual memory is available.


EINVAL

key is invalid.


Note -

pthread_setspecific() does not free its storage. If a new binding is set, the existing binding must be freed; otherwise, a memory leak can occur..