Commit e926c62c authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

imm32: Lazily allocated thread-local data.

parent f970db94
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment