wininet: Don't allocate memory for the thread error structure until it is needed.
Don't allocate memory for the thread error structure until it is needed, as it is quite large and wastes memory for threads that don't call any wininet function.
This commit is contained in:
parent
0ced865aa1
commit
d133ff9afb
|
@ -283,13 +283,6 @@ BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
|||
WININET_hModule = (HMODULE)hinstDLL;
|
||||
|
||||
case DLL_THREAD_ATTACH:
|
||||
{
|
||||
LPWITHREADERROR lpwite = HeapAlloc(GetProcessHeap(), 0, sizeof(WITHREADERROR));
|
||||
if (NULL == lpwite)
|
||||
return FALSE;
|
||||
|
||||
TlsSetValue(g_dwTlsErrIndex, (LPVOID)lpwite);
|
||||
}
|
||||
break;
|
||||
|
||||
case DLL_THREAD_DETACH:
|
||||
|
@ -651,6 +644,8 @@ BOOL WINAPI InternetGetLastResponseInfoA(LPDWORD lpdwError,
|
|||
|
||||
TRACE("\n");
|
||||
|
||||
if (lpwite)
|
||||
{
|
||||
*lpdwError = lpwite->dwError;
|
||||
if (lpwite->dwError)
|
||||
{
|
||||
|
@ -659,6 +654,12 @@ BOOL WINAPI InternetGetLastResponseInfoA(LPDWORD lpdwError,
|
|||
}
|
||||
else
|
||||
*lpdwBufferLength = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
*lpdwError = 0;
|
||||
*lpdwBufferLength = 0;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -680,6 +681,8 @@ BOOL WINAPI InternetGetLastResponseInfoW(LPDWORD lpdwError,
|
|||
|
||||
TRACE("\n");
|
||||
|
||||
if (lpwite)
|
||||
{
|
||||
*lpdwError = lpwite->dwError;
|
||||
if (lpwite->dwError)
|
||||
{
|
||||
|
@ -688,6 +691,12 @@ BOOL WINAPI InternetGetLastResponseInfoW(LPDWORD lpdwError,
|
|||
}
|
||||
else
|
||||
*lpdwBufferLength = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
*lpdwError = 0;
|
||||
*lpdwBufferLength = 0;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -3048,6 +3057,12 @@ void INTERNET_SetLastError(DWORD dwError)
|
|||
{
|
||||
LPWITHREADERROR lpwite = (LPWITHREADERROR)TlsGetValue(g_dwTlsErrIndex);
|
||||
|
||||
if (!lpwite)
|
||||
{
|
||||
lpwite = HeapAlloc(GetProcessHeap(), 0, sizeof(*lpwite));
|
||||
TlsSetValue(g_dwTlsErrIndex, lpwite);
|
||||
}
|
||||
|
||||
SetLastError(dwError);
|
||||
if(lpwite)
|
||||
lpwite->dwError = dwError;
|
||||
|
@ -3065,6 +3080,7 @@ void INTERNET_SetLastError(DWORD dwError)
|
|||
DWORD INTERNET_GetLastError(void)
|
||||
{
|
||||
LPWITHREADERROR lpwite = (LPWITHREADERROR)TlsGetValue(g_dwTlsErrIndex);
|
||||
if (!lpwite) return 0;
|
||||
/* TlsGetValue clears last error, so set it again here */
|
||||
SetLastError(lpwite->dwError);
|
||||
return lpwite->dwError;
|
||||
|
@ -3476,6 +3492,11 @@ static VOID INTERNET_ExecuteWork(void)
|
|||
LPSTR INTERNET_GetResponseBuffer(void)
|
||||
{
|
||||
LPWITHREADERROR lpwite = (LPWITHREADERROR)TlsGetValue(g_dwTlsErrIndex);
|
||||
if (!lpwite)
|
||||
{
|
||||
lpwite = HeapAlloc(GetProcessHeap(), 0, sizeof(*lpwite));
|
||||
TlsSetValue(g_dwTlsErrIndex, lpwite);
|
||||
}
|
||||
TRACE("\n");
|
||||
return lpwite->response;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue