imm32: Lazily allocated thread-local data.

oldstable
Rob Shearman 2009-02-24 14:52:57 +00:00 committed by Alexandre Julliard
parent f970db947a
commit e926c62c43
1 changed files with 10 additions and 15 deletions

View File

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