----- Original Message ----- From: <[EMAIL PROTECTED]>
In the unix world using pthreads, when you allocate
thread-local storage, you specify a callback function
to delete the storage when the thread terminates.
This callback is the second argument to
pthread_key_create(),  See, for example,

 http://www.mkssoftware.com/docs/man3/pthread_key_create.3.asp

Question:  How do you do the same thing on windows?
How do you get a thread to clean up its thread-local-storage
obtained using TlsAlloc() and TlsSetValue() when the
thread terminates?

I need an answer to this question so that I can fix
ticket #1601:  http://www.sqlite.org/cvstrac/tktview?tn=1601

Not quite so straightforward in Windows:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/thread_local_storage.asp


Excerpt of #4:
When each thread no longer needs to use a TLS index, it must free the memory whose pointer is stored in the TLS slot. When all threads have finished using a TLS index, use the TlsFree function to free the index. For example, use the following code in your DllMain during DLL_THREAD_DETACH:

 lpvBuffer = TlsGetValue(gdwTlsIndex);
 LocalFree((HLOCAL) lpvBuffer);
and the following code during DLL_PROCESS_DETACH:
TlsFree(gdwTlsIndex);

Reply via email to