On 2011-05-17 Thorsten Glaser wrote:
> Lasse Collin dixit:
> >A thread-local variable to store an error message would work with
> >all
> 
> This wouldn’t be portable at all.

To be more exact, I meant a function that would return a pointer to 
thread-specific char array. POSIX has pthread_key_create() and 
pthread_once() that can be used to implement this. I think those are 
fairly portable. I'm aware that Windows might give some gray hair, but I 
won't worry about that too much.

Maybe there is a problem if liblzma is loaded with dlopen() and later 
unloaded with dlclose(). It could leak the memory allocated for the 
thread-specific data and leak the resources associated with a 
pthread_key_t. glibc supports destructor functions that are called 
before dlcose() returns. I think it would prevent this issue, but such 
destructors aren't portable.

-- 
Lasse Collin  |  IRC: Larhzu @ IRCnet & Freenode

Reply via email to