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)
|
static IMMThreadData* IMM_GetThreadData(void)
|
||||||
{
|
{
|
||||||
return TlsGetValue(tlsIndex);
|
IMMThreadData* data = TlsGetValue(tlsIndex);
|
||||||
}
|
if (!data)
|
||||||
|
{
|
||||||
static BOOL IMM_InitThreadData(void)
|
data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
||||||
{
|
sizeof(IMMThreadData));
|
||||||
IMMThreadData* data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
TlsSetValue(tlsIndex,data);
|
||||||
sizeof(IMMThreadData));
|
TRACE("Thread Data Created\n");
|
||||||
if (!data) return FALSE;
|
}
|
||||||
|
return data;
|
||||||
TlsSetValue(tlsIndex,data);
|
|
||||||
|
|
||||||
TRACE("Thread Data Created\n");
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void IMM_FreeThreadData(void)
|
static void IMM_FreeThreadData(void)
|
||||||
|
@ -384,11 +380,10 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpReserved)
|
||||||
case DLL_PROCESS_ATTACH:
|
case DLL_PROCESS_ATTACH:
|
||||||
IMM_RegisterMessages();
|
IMM_RegisterMessages();
|
||||||
tlsIndex = TlsAlloc();
|
tlsIndex = TlsAlloc();
|
||||||
if (tlsIndex == TLS_OUT_OF_INDEXES || !IMM_InitThreadData())
|
if (tlsIndex == TLS_OUT_OF_INDEXES)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
break;
|
break;
|
||||||
case DLL_THREAD_ATTACH:
|
case DLL_THREAD_ATTACH:
|
||||||
IMM_InitThreadData();
|
|
||||||
break;
|
break;
|
||||||
case DLL_THREAD_DETACH:
|
case DLL_THREAD_DETACH:
|
||||||
IMM_FreeThreadData();
|
IMM_FreeThreadData();
|
||||||
|
|
Loading…
Reference in New Issue