CeTlsAlloc (Compact 2013)


This function allocates a thread local storage (TLS) index and sets a cleanup function for the slot. Any thread of the process can subsequently use this index to store and retrieve values that are local to the thread.

DWORD CeTlsAlloc(
    PFN_CETLSFREE pfnCleanup


[in] Specifies a cleanup function to associate with the given slot.

If successful, this function returns a valid TLS index and associates the cleanup function with the new slot. TLS_OUT_OF_INDEXES (0xFFFFFFFF) indicates failure. To get extended error information, call GetLastError.

Call this function in DLL_PROCESS_ATTACH to create a new slot and assign a custom cleanup function for this slot. The system calls the custom cleanup function when a thread using this slot exits or when the slot is cleared using CeTlsFree.

For a brief discussion of typical uses of the TLS functions, see the Remarks section of the TlsAlloc function.