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( ...@@ -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) ...@@ -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();
......
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