imm32: Lazily allocated thread-local data.
This commit is contained in:
parent
f970db947a
commit
e926c62c43
|
@ -220,19 +220,15 @@ static DWORD convert_candidatelist_AtoW(
|
|||
|
||||
static IMMThreadData* IMM_GetThreadData(void)
|
||||
{
|
||||
return TlsGetValue(tlsIndex);
|
||||
}
|
||||
|
||||
static BOOL IMM_InitThreadData(void)
|
||||
{
|
||||
IMMThreadData* data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
||||
sizeof(IMMThreadData));
|
||||
if (!data) return FALSE;
|
||||
|
||||
TlsSetValue(tlsIndex,data);
|
||||
|
||||
TRACE("Thread Data Created\n");
|
||||
return TRUE;
|
||||
IMMThreadData* data = TlsGetValue(tlsIndex);
|
||||
if (!data)
|
||||
{
|
||||
data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
||||
sizeof(IMMThreadData));
|
||||
TlsSetValue(tlsIndex,data);
|
||||
TRACE("Thread Data Created\n");
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
static void IMM_FreeThreadData(void)
|
||||
|
@ -384,11 +380,10 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpReserved)
|
|||
case DLL_PROCESS_ATTACH:
|
||||
IMM_RegisterMessages();
|
||||
tlsIndex = TlsAlloc();
|
||||
if (tlsIndex == TLS_OUT_OF_INDEXES || !IMM_InitThreadData())
|
||||
if (tlsIndex == TLS_OUT_OF_INDEXES)
|
||||
return FALSE;
|
||||
break;
|
||||
case DLL_THREAD_ATTACH:
|
||||
IMM_InitThreadData();
|
||||
break;
|
||||
case DLL_THREAD_DETACH:
|
||||
IMM_FreeThreadData();
|
||||
|
|
Loading…
Reference in New Issue