Commit 9acd1ef1 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

wininet: Consistently use the allocation macros.

parent 14d4d195
......@@ -132,14 +132,14 @@ static cookie *COOKIE_findCookie(cookie_domain *domain, LPCWSTR lpszCookieName)
/* removes a cookie from the list, if its the last cookie we also remove the domain */
static void COOKIE_deleteCookie(cookie *deadCookie, BOOL deleteDomain)
{
HeapFree(GetProcessHeap(), 0, deadCookie->lpCookieName);
HeapFree(GetProcessHeap(), 0, deadCookie->lpCookieData);
heap_free(deadCookie->lpCookieName);
heap_free(deadCookie->lpCookieData);
list_remove(&deadCookie->entry);
/* special case: last cookie, lets remove the domain to save memory */
if (list_empty(&deadCookie->parent->cookie_list) && deleteDomain)
COOKIE_deleteDomain(deadCookie->parent);
HeapFree(GetProcessHeap(), 0, deadCookie);
heap_free(deadCookie);
}
/* allocates a domain and adds it to the end */
......@@ -251,13 +251,12 @@ static void COOKIE_deleteDomain(cookie_domain *deadDomain)
COOKIE_deleteCookie(LIST_ENTRY(cursor, cookie, entry), FALSE);
list_remove(cursor);
}
HeapFree(GetProcessHeap(), 0, deadDomain->lpCookieDomain);
HeapFree(GetProcessHeap(), 0, deadDomain->lpCookiePath);
heap_free(deadDomain->lpCookieDomain);
heap_free(deadDomain->lpCookiePath);
list_remove(&deadDomain->entry);
HeapFree(GetProcessHeap(), 0, deadDomain);
heap_free(deadDomain);
}
BOOL get_cookie(const WCHAR *host, const WCHAR *path, WCHAR *cookie_data, DWORD *size)
......@@ -406,11 +405,9 @@ BOOL WINAPI InternetGetCookieA(LPCSTR lpszUrl, LPCSTR lpszCookieName,
lpCookieData, *lpdwSize, NULL, NULL );
}
}
HeapFree( GetProcessHeap(), 0, szCookieData );
HeapFree( GetProcessHeap(), 0, name );
HeapFree( GetProcessHeap(), 0, url );
heap_free( szCookieData );
heap_free( name );
heap_free( url );
return r;
}
......@@ -447,12 +444,11 @@ BOOL set_cookie(LPCWSTR domain, LPCWSTR path, LPCWSTR cookie_name, LPCWSTR cooki
if (!(ptr = strchrW(ptr,';'))) break;
*ptr++ = 0;
if (value != data)
HeapFree(GetProcessHeap(), 0, value);
if (value != data) heap_free(value);
value = heap_alloc((ptr - data) * sizeof(WCHAR));
if (value == NULL)
{
HeapFree(GetProcessHeap(), 0, data);
heap_free(data);
ERR("could not allocate the cookie value buffer\n");
return FALSE;
}
......@@ -521,8 +517,8 @@ BOOL set_cookie(LPCWSTR domain, LPCWSTR path, LPCWSTR cookie_name, LPCWSTR cooki
thisCookieDomain = COOKIE_addDomain(domain, path);
else
{
HeapFree(GetProcessHeap(),0,data);
if (value != data) HeapFree(GetProcessHeap(), 0, value);
heap_free(data);
if (value != data) heap_free(value);
return TRUE;
}
}
......@@ -535,13 +531,12 @@ BOOL set_cookie(LPCWSTR domain, LPCWSTR path, LPCWSTR cookie_name, LPCWSTR cooki
if (!expired && !COOKIE_addCookie(thisCookieDomain, cookie_name, value, expiry))
{
HeapFree(GetProcessHeap(),0,data);
if (value != data) HeapFree(GetProcessHeap(), 0, value);
heap_free(data);
if (value != data) heap_free(value);
return FALSE;
}
HeapFree(GetProcessHeap(),0,data);
if (value != data) HeapFree(GetProcessHeap(), 0, value);
heap_free(data);
if (value != data) heap_free(value);
return TRUE;
}
......@@ -593,7 +588,7 @@ BOOL WINAPI InternetSetCookieW(LPCWSTR lpszUrl, LPCWSTR lpszCookieName,
ret = set_cookie(hostName, path, cookie, data);
HeapFree(GetProcessHeap(), 0, cookie);
heap_free(cookie);
return ret;
}
return set_cookie(hostName, path, lpszCookieName, lpCookieData);
......@@ -625,10 +620,9 @@ BOOL WINAPI InternetSetCookieA(LPCSTR lpszUrl, LPCSTR lpszCookieName,
r = InternetSetCookieW( url, name, data );
HeapFree( GetProcessHeap(), 0, data );
HeapFree( GetProcessHeap(), 0, name );
HeapFree( GetProcessHeap(), 0, url );
heap_free( data );
heap_free( name );
heap_free( url );
return r;
}
......
......@@ -264,7 +264,7 @@ static BOOL WININET_SetAuthorization( HINTERNET hRequest, LPWSTR username,
q = heap_strdupW(password);
if( !q )
{
HeapFree(GetProcessHeap(), 0, username);
heap_free(username);
goto done;
}
......@@ -272,18 +272,18 @@ static BOOL WININET_SetAuthorization( HINTERNET hRequest, LPWSTR username,
{
appinfo_t *hIC = session->appInfo;
HeapFree(GetProcessHeap(), 0, hIC->proxyUsername);
heap_free(hIC->proxyUsername);
hIC->proxyUsername = p;
HeapFree(GetProcessHeap(), 0, hIC->proxyPassword);
heap_free(hIC->proxyPassword);
hIC->proxyPassword = q;
}
else
{
HeapFree(GetProcessHeap(), 0, session->userName);
heap_free(session->userName);
session->userName = p;
HeapFree(GetProcessHeap(), 0, session->password);
heap_free(session->password);
session->password = q;
}
......
......@@ -210,7 +210,7 @@ static PCCERT_CONTEXT X509_to_cert_context(X509 *cert)
if (malloced)
free(buffer);
else
HeapFree(GetProcessHeap(),0,buffer);
heap_free(buffer);
return ret;
}
......@@ -482,7 +482,7 @@ static DWORD init_openssl(void)
pCRYPTO_set_id_callback(ssl_thread_id);
num_ssl_locks = pCRYPTO_num_locks();
ssl_locks = HeapAlloc(GetProcessHeap(), 0, num_ssl_locks * sizeof(CRITICAL_SECTION));
ssl_locks = heap_alloc(num_ssl_locks * sizeof(CRITICAL_SECTION));
if(!ssl_locks)
return ERROR_OUTOFMEMORY;
......@@ -582,7 +582,7 @@ void NETCON_unload(void)
{
int i;
for (i = 0; i < num_ssl_locks; i++) DeleteCriticalSection(&ssl_locks[i]);
HeapFree(GetProcessHeap(), 0, ssl_locks);
heap_free(ssl_locks);
}
#endif
}
......
......@@ -469,15 +469,15 @@ static BOOL URLCacheContainers_AddContainer(LPCWSTR cache_prefix, LPCWSTR path,
pContainer->path = heap_strdupW(path);
if (!pContainer->path)
{
HeapFree(GetProcessHeap(), 0, pContainer);
heap_free(pContainer);
return FALSE;
}
pContainer->cache_prefix = heap_alloc((cache_prefix_len + 1) * sizeof(WCHAR));
if (!pContainer->cache_prefix)
{
HeapFree(GetProcessHeap(), 0, pContainer->path);
HeapFree(GetProcessHeap(), 0, pContainer);
heap_free(pContainer->path);
heap_free(pContainer);
return FALSE;
}
......@@ -489,8 +489,8 @@ static BOOL URLCacheContainers_AddContainer(LPCWSTR cache_prefix, LPCWSTR path,
if ((pContainer->hMutex = CreateMutexW(NULL, FALSE, mutex_name)) == NULL)
{
ERR("couldn't create mutex (error is %d)\n", GetLastError());
HeapFree(GetProcessHeap(), 0, pContainer->path);
HeapFree(GetProcessHeap(), 0, pContainer);
heap_free(pContainer->path);
heap_free(pContainer);
return FALSE;
}
......@@ -505,9 +505,9 @@ static void URLCacheContainer_DeleteContainer(URLCACHECONTAINER * pContainer)
URLCacheContainer_CloseIndex(pContainer);
CloseHandle(pContainer->hMutex);
HeapFree(GetProcessHeap(), 0, pContainer->path);
HeapFree(GetProcessHeap(), 0, pContainer->cache_prefix);
HeapFree(GetProcessHeap(), 0, pContainer);
heap_free(pContainer->path);
heap_free(pContainer->cache_prefix);
heap_free(pContainer);
}
void URLCacheContainers_CreateDefaults(void)
......@@ -607,7 +607,7 @@ static DWORD URLCacheContainers_FindContainerA(LPCSTR lpszUrl, URLCACHECONTAINER
return ERROR_OUTOFMEMORY;
ret = URLCacheContainers_FindContainerW(url, ppContainer);
HeapFree(GetProcessHeap(), 0, url);
heap_free(url);
return ret;
}
......@@ -1263,7 +1263,7 @@ static BOOL URLCache_FindHashW(LPCURLCACHE_HEADER pHeader, LPCWSTR lpszUrl, stru
}
ret = URLCache_FindHash(pHeader, urlA, ppHashEntry);
HeapFree(GetProcessHeap(), 0, urlA);
heap_free(urlA);
return ret;
}
......@@ -2328,32 +2328,31 @@ BOOL WINAPI CreateUrlCacheEntryA(
if (lpszUrlName && (url_name = heap_strdupAtoW(lpszUrlName)))
{
if (!lpszFileExtension || (file_extension = heap_strdupAtoW(lpszFileExtension)))
{
if (CreateUrlCacheEntryW(url_name, dwExpectedFileSize, file_extension, file_name, dwReserved))
{
if (WideCharToMultiByte(CP_ACP, 0, file_name, -1, lpszFileName, MAX_PATH, NULL, NULL) < MAX_PATH)
{
bSuccess = TRUE;
}
else
{
dwError = GetLastError();
}
}
else
{
dwError = GetLastError();
}
HeapFree(GetProcessHeap(), 0, file_extension);
}
else
{
dwError = GetLastError();
}
HeapFree(GetProcessHeap(), 0, url_name);
if (!bSuccess)
SetLastError(dwError);
if (!lpszFileExtension || (file_extension = heap_strdupAtoW(lpszFileExtension)))
{
if (CreateUrlCacheEntryW(url_name, dwExpectedFileSize, file_extension, file_name, dwReserved))
{
if (WideCharToMultiByte(CP_ACP, 0, file_name, -1, lpszFileName, MAX_PATH, NULL, NULL) < MAX_PATH)
{
bSuccess = TRUE;
}
else
{
dwError = GetLastError();
}
}
else
{
dwError = GetLastError();
}
heap_free(file_extension);
}
else
{
dwError = GetLastError();
}
heap_free(url_name);
if (!bSuccess) SetLastError(dwError);
}
return bSuccess;
}
......@@ -2796,8 +2795,8 @@ static BOOL CommitUrlCacheEntryInternal(
cleanup:
URLCacheContainer_UnlockIndex(pContainer, pHeader);
HeapFree(GetProcessHeap(), 0, lpszUrlNameA);
HeapFree(GetProcessHeap(), 0, lpszFileExtensionA);
heap_free(lpszUrlNameA);
heap_free(lpszFileExtensionA);
if (error == ERROR_SUCCESS)
return TRUE;
......@@ -2867,11 +2866,10 @@ BOOL WINAPI CommitUrlCacheEntryA(
file_extension, original_url);
cleanup:
HeapFree(GetProcessHeap(), 0, original_url);
HeapFree(GetProcessHeap(), 0, file_extension);
HeapFree(GetProcessHeap(), 0, local_file_name);
HeapFree(GetProcessHeap(), 0, url_name);
heap_free(original_url);
heap_free(file_extension);
heap_free(local_file_name);
heap_free(url_name);
return bSuccess;
}
......@@ -2918,7 +2916,7 @@ BOOL WINAPI CommitUrlCacheEntryW(
}
if (header_info)
{
HeapFree(GetProcessHeap(), 0, header_info);
heap_free(header_info);
if (!bSuccess)
SetLastError(dwError);
}
......@@ -3103,12 +3101,8 @@ BOOL WINAPI UnlockUrlCacheEntryStream(
if (!UnlockUrlCacheEntryFileA(pStream->lpszUrl, 0))
return FALSE;
/* close file handle */
CloseHandle(pStream->hFile);
/* free allocated space */
HeapFree(GetProcessHeap(), 0, pStream);
heap_free(pStream);
return TRUE;
}
......@@ -3184,7 +3178,7 @@ BOOL WINAPI DeleteUrlCacheEntryW(LPCWSTR lpszUrlName)
error = URLCacheContainers_FindContainerW(lpszUrlName, &pContainer);
if (error != ERROR_SUCCESS)
{
HeapFree(GetProcessHeap(), 0, urlA);
heap_free(urlA);
SetLastError(error);
return FALSE;
}
......@@ -3192,14 +3186,14 @@ BOOL WINAPI DeleteUrlCacheEntryW(LPCWSTR lpszUrlName)
error = URLCacheContainer_OpenIndex(pContainer);
if (error != ERROR_SUCCESS)
{
HeapFree(GetProcessHeap(), 0, urlA);
heap_free(urlA);
SetLastError(error);
return FALSE;
}
if (!(pHeader = URLCacheContainer_LockIndex(pContainer)))
{
HeapFree(GetProcessHeap(), 0, urlA);
heap_free(urlA);
return FALSE;
}
......@@ -3207,7 +3201,7 @@ BOOL WINAPI DeleteUrlCacheEntryW(LPCWSTR lpszUrlName)
{
URLCacheContainer_UnlockIndex(pContainer, pHeader);
TRACE("entry %s not found!\n", debugstr_a(urlA));
HeapFree(GetProcessHeap(), 0, urlA);
heap_free(urlA);
SetLastError(ERROR_FILE_NOT_FOUND);
return FALSE;
}
......@@ -3215,8 +3209,7 @@ BOOL WINAPI DeleteUrlCacheEntryW(LPCWSTR lpszUrlName)
ret = DeleteUrlCacheEntryInternal(pHeader, pHashEntry);
URLCacheContainer_UnlockIndex(pContainer, pHeader);
HeapFree(GetProcessHeap(), 0, urlA);
heap_free(urlA);
return ret;
}
......@@ -3360,7 +3353,7 @@ INTERNETAPI HANDLE WINAPI FindFirstUrlCacheEntryA(LPCSTR lpszUrlSearchPattern,
pEntryHandle->lpszUrlSearchPattern = heap_strdupAtoW(lpszUrlSearchPattern);
if (!pEntryHandle->lpszUrlSearchPattern)
{
HeapFree(GetProcessHeap(), 0, pEntryHandle);
heap_free(pEntryHandle);
return NULL;
}
}
......@@ -3372,7 +3365,7 @@ INTERNETAPI HANDLE WINAPI FindFirstUrlCacheEntryA(LPCSTR lpszUrlSearchPattern,
if (!FindNextUrlCacheEntryA(pEntryHandle, lpFirstCacheEntryInfo, lpdwFirstCacheEntryInfoBufferSize))
{
HeapFree(GetProcessHeap(), 0, pEntryHandle);
heap_free(pEntryHandle);
return NULL;
}
return pEntryHandle;
......@@ -3399,7 +3392,7 @@ INTERNETAPI HANDLE WINAPI FindFirstUrlCacheEntryW(LPCWSTR lpszUrlSearchPattern,
pEntryHandle->lpszUrlSearchPattern = heap_strdupW(lpszUrlSearchPattern);
if (!pEntryHandle->lpszUrlSearchPattern)
{
HeapFree(GetProcessHeap(), 0, pEntryHandle);
heap_free(pEntryHandle);
return NULL;
}
}
......@@ -3411,7 +3404,7 @@ INTERNETAPI HANDLE WINAPI FindFirstUrlCacheEntryW(LPCWSTR lpszUrlSearchPattern,
if (!FindNextUrlCacheEntryW(pEntryHandle, lpFirstCacheEntryInfo, lpdwFirstCacheEntryInfoBufferSize))
{
HeapFree(GetProcessHeap(), 0, pEntryHandle);
heap_free(pEntryHandle);
return NULL;
}
return pEntryHandle;
......@@ -3545,9 +3538,8 @@ BOOL WINAPI FindCloseUrlCache(HANDLE hEnumHandle)
}
pEntryHandle->dwMagic = 0;
HeapFree(GetProcessHeap(), 0, pEntryHandle->lpszUrlSearchPattern);
HeapFree(GetProcessHeap(), 0, pEntryHandle);
heap_free(pEntryHandle->lpszUrlSearchPattern);
heap_free(pEntryHandle);
return TRUE;
}
......
......@@ -184,7 +184,7 @@ BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
hints.ai_family = AF_INET;
ret = getaddrinfo( name, NULL, &hints, &res );
HeapFree( GetProcessHeap(), 0, name );
heap_free( name );
if (ret != 0)
{
TRACE("failed to get IPv4 address of %s (%s), retrying with IPv6\n", debugstr_w(lpszServerName), gai_strerror(ret));
......@@ -219,7 +219,7 @@ BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
#else
EnterCriticalSection( &cs_gethostbyname );
phe = gethostbyname(name);
HeapFree( GetProcessHeap(), 0, name );
heap_free( name );
if (NULL == phe)
{
......@@ -341,7 +341,7 @@ VOID INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR dwContext,
TRACE(" end callback().\n");
if(lpvNewInfo != lpvStatusInfo)
HeapFree(GetProcessHeap(), 0, lpvNewInfo);
heap_free(lpvNewInfo);
}
static void SendAsyncCallbackProc(WORKREQUEST *workRequest)
......@@ -355,7 +355,7 @@ static void SendAsyncCallbackProc(WORKREQUEST *workRequest)
req->dwStatusInfoLength);
/* And frees the copy of the status info */
HeapFree(GetProcessHeap(), 0, req->lpvStatusInfo);
heap_free(req->lpvStatusInfo);
}
void SendAsyncCallback(object_header_t *hdr, DWORD_PTR dwContext,
......
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