From: Alex Henrie alexhenrie24@gmail.com
--- dlls/wininet/cookie.c | 126 +++++----- dlls/wininet/dialogs.c | 14 +- dlls/wininet/ftp.c | 201 ++++++++-------- dlls/wininet/http.c | 441 ++++++++++++++++++----------------- dlls/wininet/internet.c | 329 +++++++++++++------------- dlls/wininet/internet.h | 53 +---- dlls/wininet/netconnection.c | 32 +-- dlls/wininet/urlcache.c | 122 +++++----- dlls/wininet/utility.c | 8 +- 9 files changed, 648 insertions(+), 678 deletions(-)
diff --git a/dlls/wininet/cookie.c b/dlls/wininet/cookie.c index 7db5f4d2f5b..dd43485658b 100644 --- a/dlls/wininet/cookie.c +++ b/dlls/wininet/cookie.c @@ -118,13 +118,13 @@ static cookie_domain_t *get_cookie_domain(substr_t domain, BOOL create) if(!create) return prev_domain;
- current_domain = heap_alloc(sizeof(*current_domain)); + current_domain = malloc(sizeof(*current_domain)); if(!current_domain) return NULL;
- current_domain->domain = heap_strndupW(subdomain_ptr, domain.str + domain.len - subdomain_ptr); + current_domain->domain = strndupW(subdomain_ptr, domain.str + domain.len - subdomain_ptr); if(!current_domain->domain) { - heap_free(current_domain); + free(current_domain); return NULL; }
@@ -158,7 +158,7 @@ static WCHAR *create_cookie_url(substr_t domain, substr_t path, substr_t *ret_pa
/* user_len already accounts for terminating NULL */ len = ARRAY_SIZE(cookie_prefix) + user_len + 1 /* @ */ + domain.len + path.len; - url = heap_alloc(len * sizeof(WCHAR)); + url = malloc(len * sizeof(WCHAR)); if(!url) return NULL;
@@ -166,7 +166,7 @@ static WCHAR *create_cookie_url(substr_t domain, substr_t path, substr_t *ret_pa p = url + ARRAY_SIZE(cookie_prefix);
if(!GetUserNameW(p, &user_len)) { - heap_free(url); + free(url); return NULL; } p += user_len; @@ -205,13 +205,13 @@ static cookie_container_t *get_cookie_container(substr_t domain, substr_t path, if(!create) return NULL;
- cookie_container = heap_alloc(sizeof(*cookie_container)); + cookie_container = malloc(sizeof(*cookie_container)); if(!cookie_container) return NULL;
cookie_container->cookie_url = create_cookie_url(substrz(cookie_domain->domain), path, &cookie_container->path); if(!cookie_container->cookie_url) { - heap_free(cookie_container); + free(cookie_container); return NULL; }
@@ -233,16 +233,16 @@ static void delete_cookie(cookie_t *cookie) { list_remove(&cookie->entry);
- heap_free(cookie->name); - heap_free(cookie->data); - heap_free(cookie); + free(cookie->name); + free(cookie->data); + free(cookie); }
static cookie_t *alloc_cookie(substr_t name, substr_t data, FILETIME expiry, FILETIME create_time, DWORD flags) { cookie_t *new_cookie;
- new_cookie = heap_alloc_zero(sizeof(*new_cookie)); + new_cookie = calloc(1, sizeof(*new_cookie)); if(!new_cookie) return NULL;
@@ -251,12 +251,12 @@ static cookie_t *alloc_cookie(substr_t name, substr_t data, FILETIME expiry, FIL new_cookie->flags = flags; list_init(&new_cookie->entry);
- if(name.str && !(new_cookie->name = heap_strndupW(name.str, name.len))) { + if(name.str && !(new_cookie->name = strndupW(name.str, name.len))) { delete_cookie(new_cookie); return NULL; }
- if(data.str && !(new_cookie->data = heap_strndupW(data.str, data.len))) { + if(data.str && !(new_cookie->data = strndupW(data.str, data.len))) { delete_cookie(new_cookie); return NULL; } @@ -320,18 +320,18 @@ static BOOL load_persistent_cookie(substr_t domain, substr_t path) RetrieveUrlCacheEntryStreamW(cookie_container->cookie_url, NULL, &size, FALSE, 0); if(GetLastError() != ERROR_INSUFFICIENT_BUFFER) return TRUE; - info = heap_alloc(size); + info = malloc(size); if(!info) return FALSE; cookie = RetrieveUrlCacheEntryStreamW(cookie_container->cookie_url, info, &size, FALSE, 0); size = info->dwSizeLow; - heap_free(info); + free(info); if(!cookie) return FALSE;
- if(!(str = heap_alloc(size+1)) || !ReadUrlCacheEntryStream(cookie, 0, str, &size, 0)) { + if(!(str = malloc(size + 1)) || !ReadUrlCacheEntryStream(cookie, 0, str, &size, 0)) { UnlockUrlCacheEntryStream(cookie, 0); - heap_free(str); + free(str); return FALSE; } str[size] = 0; @@ -343,14 +343,14 @@ static BOOL load_persistent_cookie(substr_t domain, substr_t path) if(!pend) break; *pend = 0; - name = heap_strdupAtoW(pbeg); + name = strdupAtoW(pbeg);
pbeg = pend+1; pend = strchr(pbeg, '\n'); if(!pend) break; *pend = 0; - data = heap_strdupAtoW(pbeg); + data = strdupAtoW(pbeg);
pbeg = strchr(pend+1, '\n'); if(!pbeg) @@ -379,13 +379,13 @@ static BOOL load_persistent_cookie(substr_t domain, substr_t path)
replace_cookie(cookie_container, new_cookie); }else { - heap_free(name); - heap_free(data); + free(name); + free(data); } } - heap_free(str); - heap_free(name); - heap_free(data); + free(str); + free(name); + free(data);
return TRUE; } @@ -436,50 +436,50 @@ static BOOL save_persistent_cookie(cookie_container_t *container) if(cookie_container->flags & INTERNET_COOKIE_IS_SESSION) continue;
- dyn_buf = heap_strdupWtoA(cookie_container->name); + dyn_buf = strdupWtoA(cookie_container->name); if(!dyn_buf || !WriteFile(cookie_handle, dyn_buf, strlen(dyn_buf), &bytes_written, NULL)) { - heap_free(dyn_buf); + free(dyn_buf); do_save = FALSE; break; } - heap_free(dyn_buf); + free(dyn_buf); if(!WriteFile(cookie_handle, "\n", 1, &bytes_written, NULL)) { do_save = FALSE; break; }
- dyn_buf = heap_strdupWtoA(cookie_container->data); + dyn_buf = strdupWtoA(cookie_container->data); if(!dyn_buf || !WriteFile(cookie_handle, dyn_buf, strlen(dyn_buf), &bytes_written, NULL)) { - heap_free(dyn_buf); + free(dyn_buf); do_save = FALSE; break; } - heap_free(dyn_buf); + free(dyn_buf); if(!WriteFile(cookie_handle, "\n", 1, &bytes_written, NULL)) { do_save = FALSE; break; }
- dyn_buf = heap_strdupWtoA(container->domain->domain); + dyn_buf = strdupWtoA(container->domain->domain); if(!dyn_buf || !WriteFile(cookie_handle, dyn_buf, strlen(dyn_buf), &bytes_written, NULL)) { - heap_free(dyn_buf); + free(dyn_buf); do_save = FALSE; break; } - heap_free(dyn_buf); + free(dyn_buf);
len = WideCharToMultiByte(CP_ACP, 0, container->path.str, container->path.len, NULL, 0, NULL, NULL); - dyn_buf = heap_alloc(len+1); + dyn_buf = malloc(len + 1); if(dyn_buf) { WideCharToMultiByte(CP_ACP, 0, container->path.str, container->path.len, dyn_buf, len, NULL, NULL); dyn_buf[len] = 0; } if(!dyn_buf || !WriteFile(cookie_handle, dyn_buf, strlen(dyn_buf), &bytes_written, NULL)) { - heap_free(dyn_buf); + free(dyn_buf); do_save = FALSE; break; } - heap_free(dyn_buf); + free(dyn_buf);
sprintf(buf, "\n%lu\n%lu\n%lu\n%lu\n%lu\n*\n", cookie_container->flags, cookie_container->expiry.dwLowDateTime, cookie_container->expiry.dwHighDateTime, @@ -583,12 +583,12 @@ static DWORD get_cookie(substr_t host, substr_t path, DWORD flags, cookie_set_t continue;
if(!res->size) { - res->cookies = heap_alloc(4*sizeof(*res->cookies)); + res->cookies = malloc(4 * sizeof(*res->cookies)); if(!res->cookies) continue; res->size = 4; }else if(res->cnt == res->size) { - cookie_t **new_cookies = heap_realloc(res->cookies, res->size*2*sizeof(*res->cookies)); + cookie_t **new_cookies = realloc(res->cookies, res->size * 2 * sizeof(*res->cookies)); if(!new_cookies) continue; res->cookies = new_cookies; @@ -657,13 +657,13 @@ DWORD get_cookie_header(const WCHAR *host, const WCHAR *path, WCHAR **ret) if(cookie_set.cnt) { WCHAR *header, *ptr;
- ptr = header = heap_alloc(sizeof(cookieW) + (cookie_set.string_len + 3 /* crlf0 */) * sizeof(WCHAR)); + ptr = header = malloc(sizeof(cookieW) + (cookie_set.string_len + 3 /* crlf0 */) * sizeof(WCHAR)); if(header) { memcpy(ptr, cookieW, sizeof(cookieW)); ptr += ARRAY_SIZE(cookieW);
cookie_set_to_string(&cookie_set, ptr); - heap_free(cookie_set.cookies); + free(cookie_set.cookies); ptr += cookie_set.string_len;
*ptr++ = '\r'; @@ -698,14 +698,14 @@ static void free_cookie_domain_list(struct list *list) while(!list_empty(&container->cookie_list)) delete_cookie(LIST_ENTRY(list_head(&container->cookie_list), cookie_t, entry));
- heap_free(container->cookie_url); + free(container->cookie_url); list_remove(&container->entry); - heap_free(container); + free(container); }
- heap_free(domain->domain); + free(domain->domain); list_remove(&domain->entry); - heap_free(domain); + free(domain); } }
@@ -775,7 +775,7 @@ BOOL WINAPI InternetGetCookieExW(LPCWSTR lpszUrl, LPCWSTR lpszCookieName, ret = FALSE; }
- heap_free(cookie_set.cookies); + free(cookie_set.cookies); LeaveCriticalSection(&cookie_cs); return ret; } @@ -812,15 +812,15 @@ BOOL WINAPI InternetGetCookieExA(LPCSTR lpszUrl, LPCSTR lpszCookieName, TRACE("(%s %s %p %p(%lu) %lx %p)\n", debugstr_a(lpszUrl), debugstr_a(lpszCookieName), lpCookieData, lpdwSize, lpdwSize ? *lpdwSize : 0, flags, reserved);
- url = heap_strdupAtoW(lpszUrl); - name = heap_strdupAtoW(lpszCookieName); + url = strdupAtoW(lpszUrl); + name = strdupAtoW(lpszCookieName);
r = InternetGetCookieExW( url, name, NULL, &len, flags, reserved ); if( r ) { WCHAR *szCookieData;
- szCookieData = heap_alloc(len * sizeof(WCHAR)); + szCookieData = malloc(len * sizeof(WCHAR)); if( !szCookieData ) { r = FALSE; @@ -841,12 +841,12 @@ BOOL WINAPI InternetGetCookieExA(LPCSTR lpszUrl, LPCSTR lpszCookieName, } }
- heap_free( szCookieData ); + free( szCookieData ); } } *lpdwSize = size; - heap_free( name ); - heap_free( url ); + free(name); + free(url); return r; }
@@ -1141,15 +1141,15 @@ BOOL WINAPI InternetSetCookieA(LPCSTR lpszUrl, LPCSTR lpszCookieName, TRACE("(%s,%s,%s)\n", debugstr_a(lpszUrl), debugstr_a(lpszCookieName), debugstr_a(lpCookieData));
- url = heap_strdupAtoW(lpszUrl); - name = heap_strdupAtoW(lpszCookieName); - data = heap_strdupAtoW(lpCookieData); + url = strdupAtoW(lpszUrl); + name = strdupAtoW(lpszCookieName); + data = strdupAtoW(lpCookieData);
r = InternetSetCookieW( url, name, data );
- heap_free( data ); - heap_free( name ); - heap_free( url ); + free(data); + free(name); + free(url); return r; }
@@ -1167,15 +1167,15 @@ DWORD WINAPI InternetSetCookieExA( LPCSTR lpszURL, LPCSTR lpszCookieName, LPCSTR TRACE("(%s, %s, %s, %lx, %Ix)\n", debugstr_a(lpszURL), debugstr_a(lpszCookieName), debugstr_a(lpszCookieData), dwFlags, dwReserved);
- url = heap_strdupAtoW(lpszURL); - name = heap_strdupAtoW(lpszCookieName); - data = heap_strdupAtoW(lpszCookieData); + url = strdupAtoW(lpszURL); + name = strdupAtoW(lpszCookieName); + data = strdupAtoW(lpszCookieData);
r = InternetSetCookieExW(url, name, data, dwFlags, dwReserved);
- heap_free( data ); - heap_free( name ); - heap_free( url ); + free(data); + free(name); + free(url); return r; }
diff --git a/dlls/wininet/dialogs.c b/dlls/wininet/dialogs.c index 6b53a9f3272..bd9b877d5d6 100644 --- a/dlls/wininet/dialogs.c +++ b/dlls/wininet/dialogs.c @@ -185,14 +185,14 @@ static BOOL WININET_SetAuthorization( http_request_t *request, LPWSTR username, http_session_t *session = request->session; LPWSTR p, q;
- p = heap_strdupW(username); + p = wcsdup(username); if( !p ) return FALSE;
- q = heap_strdupW(password); + q = wcsdup(password); if( !q ) { - heap_free(p); + free(p); return FALSE; }
@@ -200,18 +200,18 @@ static BOOL WININET_SetAuthorization( http_request_t *request, LPWSTR username, { appinfo_t *hIC = session->appInfo;
- heap_free(hIC->proxyUsername); + free(hIC->proxyUsername); hIC->proxyUsername = p;
- heap_free(hIC->proxyPassword); + free(hIC->proxyPassword); hIC->proxyPassword = q; } else { - heap_free(session->userName); + free(session->userName); session->userName = p;
- heap_free(session->password); + free(session->password); session->password = q; }
diff --git a/dlls/wininet/ftp.c b/dlls/wininet/ftp.c index 80efeb2bf37..cf6555c63e2 100644 --- a/dlls/wininet/ftp.c +++ b/dlls/wininet/ftp.c @@ -224,12 +224,12 @@ BOOL WINAPI FtpPutFileA(HINTERNET hConnect, LPCSTR lpszLocalFile, LPWSTR lpwzNewRemoteFile; BOOL ret;
- lpwzLocalFile = heap_strdupAtoW(lpszLocalFile); - lpwzNewRemoteFile = heap_strdupAtoW(lpszNewRemoteFile); + lpwzLocalFile = strdupAtoW(lpszLocalFile); + lpwzNewRemoteFile = strdupAtoW(lpszNewRemoteFile); ret = FtpPutFileW(hConnect, lpwzLocalFile, lpwzNewRemoteFile, dwFlags, dwContext); - heap_free(lpwzLocalFile); - heap_free(lpwzNewRemoteFile); + free(lpwzLocalFile); + free(lpwzNewRemoteFile); return ret; }
@@ -251,8 +251,8 @@ static void AsyncFtpPutFileProc(task_header_t *hdr) FTP_FtpPutFileW(session, task->local_file, task->remote_file, task->flags, task->context);
- heap_free(task->local_file); - heap_free(task->remote_file); + free(task->local_file); + free(task->remote_file); }
/*********************************************************************** @@ -308,8 +308,8 @@ BOOL WINAPI FtpPutFileW(HINTERNET hConnect, LPCWSTR lpszLocalFile, { put_file_task_t *task = alloc_async_task(&lpwfs->hdr, AsyncFtpPutFileProc, sizeof(*task));
- task->local_file = heap_strdupW(lpszLocalFile); - task->remote_file = heap_strdupW(lpszNewRemoteFile); + task->local_file = wcsdup(lpszLocalFile); + task->remote_file = wcsdup(lpszNewRemoteFile); task->flags = dwFlags; task->context = dwContext;
@@ -416,10 +416,10 @@ BOOL WINAPI FtpSetCurrentDirectoryA(HINTERNET hConnect, LPCSTR lpszDirectory) { LPWSTR lpwzDirectory; BOOL ret; - - lpwzDirectory = heap_strdupAtoW(lpszDirectory); + + lpwzDirectory = strdupAtoW(lpszDirectory); ret = FtpSetCurrentDirectoryW(hConnect, lpwzDirectory); - heap_free(lpwzDirectory); + free(lpwzDirectory); return ret; }
@@ -436,7 +436,7 @@ static void AsyncFtpSetCurrentDirectoryProc(task_header_t *hdr) TRACE("%p\n", session);
FTP_FtpSetCurrentDirectoryW(session, task->directory); - heap_free(task->directory); + free(task->directory); }
/*********************************************************************** @@ -482,7 +482,7 @@ BOOL WINAPI FtpSetCurrentDirectoryW(HINTERNET hConnect, LPCWSTR lpszDirectory) directory_task_t *task;
task = alloc_async_task(&lpwfs->hdr, AsyncFtpSetCurrentDirectoryProc, sizeof(*task)); - task->directory = heap_strdupW(lpszDirectory); + task->directory = wcsdup(lpszDirectory);
r = res_to_le(INTERNET_AsyncCall(&task->hdr)); } @@ -563,10 +563,10 @@ BOOL WINAPI FtpCreateDirectoryA(HINTERNET hConnect, LPCSTR lpszDirectory) { LPWSTR lpwzDirectory; BOOL ret; - - lpwzDirectory = heap_strdupAtoW(lpszDirectory); + + lpwzDirectory = strdupAtoW(lpszDirectory); ret = FtpCreateDirectoryW(hConnect, lpwzDirectory); - heap_free(lpwzDirectory); + free(lpwzDirectory); return ret; }
@@ -579,7 +579,7 @@ static void AsyncFtpCreateDirectoryProc(task_header_t *hdr) TRACE(" %p\n", session);
FTP_FtpCreateDirectoryW(session, task->directory); - heap_free(task->directory); + free(task->directory); }
/*********************************************************************** @@ -629,7 +629,7 @@ BOOL WINAPI FtpCreateDirectoryW(HINTERNET hConnect, LPCWSTR lpszDirectory) directory_task_t *task;
task = alloc_async_task(&lpwfs->hdr, AsyncFtpCreateDirectoryProc, sizeof(*task)); - task->directory = heap_strdupW(lpszDirectory); + task->directory = wcsdup(lpszDirectory);
r = res_to_le(INTERNET_AsyncCall(&task->hdr)); } @@ -709,12 +709,12 @@ HINTERNET WINAPI FtpFindFirstFileA(HINTERNET hConnect, WIN32_FIND_DATAW wfd; LPWIN32_FIND_DATAW lpFindFileDataW; HINTERNET ret; - - lpwzSearchFile = heap_strdupAtoW(lpszSearchFile); + + lpwzSearchFile = strdupAtoW(lpszSearchFile); lpFindFileDataW = lpFindFileData?&wfd:NULL; ret = FtpFindFirstFileW(hConnect, lpwzSearchFile, lpFindFileDataW, dwFlags, dwContext); - heap_free(lpwzSearchFile); - + free(lpwzSearchFile); + if (ret && lpFindFileData) WININET_find_data_WtoA(lpFindFileDataW, lpFindFileData);
@@ -737,7 +737,7 @@ static void AsyncFtpFindFirstFileProc(task_header_t *hdr) TRACE("%p\n", session);
FTP_FtpFindFirstFileW(session, task->search_file, task->find_file_data, task->flags, task->context); - heap_free(task->search_file); + free(task->search_file); }
/*********************************************************************** @@ -776,7 +776,7 @@ HINTERNET WINAPI FtpFindFirstFileW(HINTERNET hConnect, find_first_file_task_t *task;
task = alloc_async_task(&lpwfs->hdr, AsyncFtpFindFirstFileProc, sizeof(*task)); - task->search_file = heap_strdupW(lpszSearchFile); + task->search_file = wcsdup(lpszSearchFile); task->find_file_data = lpFindFileData; task->flags = dwFlags; task->context = dwContext; @@ -837,7 +837,7 @@ static HINTERNET FTP_FtpFindFirstFileW(ftp_session_t *lpwfs, if ((p = wcsrchr( name, '/' ))) name = p + 1; if (name != lpszSearchFile) { - lpszSearchPath = heap_strndupW(lpszSearchFile, name - lpszSearchFile); + lpszSearchPath = strndupW(lpszSearchFile, name - lpszSearchFile); lpszSearchFile = name; } } @@ -868,7 +868,7 @@ static HINTERNET FTP_FtpFindFirstFileW(ftp_session_t *lpwfs, }
lend: - heap_free(lpszSearchPath); + free(lpszSearchPath);
if (lpwfs->lstnSocket != -1) { @@ -920,7 +920,7 @@ BOOL WINAPI FtpGetCurrentDirectoryA(HINTERNET hFtpSession, LPSTR lpszCurrentDire len = *lpdwCurrentDirectory; if(lpszCurrentDirectory) { - dir = heap_alloc(len * sizeof(WCHAR)); + dir = malloc(len * sizeof(WCHAR)); if (NULL == dir) { INTERNET_SetLastError(ERROR_OUTOFMEMORY); @@ -934,7 +934,7 @@ BOOL WINAPI FtpGetCurrentDirectoryA(HINTERNET hFtpSession, LPSTR lpszCurrentDire WideCharToMultiByte(CP_ACP, 0, dir, -1, lpszCurrentDirectory, len, NULL, NULL);
if (lpdwCurrentDirectory) *lpdwCurrentDirectory = len; - heap_free(dir); + free(dir); return ret; }
@@ -1060,7 +1060,7 @@ static BOOL FTP_FtpGetCurrentDirectoryW(ftp_session_t *lpwfs, LPWSTR lpszCurrent if (nResCode == 257) /* Extract directory name */ { DWORD firstpos, lastpos, len; - LPWSTR lpszResponseBuffer = heap_strdupAtoW(INTERNET_GetResponseBuffer()); + WCHAR *lpszResponseBuffer = strdupAtoW(INTERNET_GetResponseBuffer());
for (firstpos = 0, lastpos = 0; lpszResponseBuffer[lastpos]; lastpos++) { @@ -1082,7 +1082,7 @@ static BOOL FTP_FtpGetCurrentDirectoryW(ftp_session_t *lpwfs, LPWSTR lpszCurrent } else INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
- heap_free(lpszResponseBuffer); + free(lpszResponseBuffer); } else FTP_SetResponseError(nResCode); @@ -1121,7 +1121,7 @@ static void FTPFILE_Destroy(object_header_t *hdr) if (lpwh->cache_file_handle != INVALID_HANDLE_VALUE) CloseHandle(lpwh->cache_file_handle);
- heap_free(lpwh->cache_file); + free(lpwh->cache_file);
if (!lpwh->session_deleted) lpwfs->download_in_progress = NULL; @@ -1373,27 +1373,27 @@ static HINTERNET FTP_FtpOpenFileW(ftp_session_t *lpwfs, uc.lpszHostName = lpwfs->servername; uc.nPort = lpwfs->serverport; uc.lpszUserName = lpwfs->lpszUserName; - uc.lpszUrlPath = heap_strdupW(lpszFileName); + uc.lpszUrlPath = wcsdup(lpszFileName);
if (!InternetCreateUrlW(&uc, 0, NULL, &len) && GetLastError() == ERROR_INSUFFICIENT_BUFFER) { - WCHAR *url = heap_alloc(len * sizeof(WCHAR)); + WCHAR *url = malloc(len * sizeof(WCHAR));
if (url && InternetCreateUrlW(&uc, 0, url, &len) && CreateUrlCacheEntryW(url, 0, NULL, filename, 0)) { - lpwh->cache_file = heap_strdupW(filename); + lpwh->cache_file = wcsdup(filename); lpwh->cache_file_handle = CreateFileW(filename, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (lpwh->cache_file_handle == INVALID_HANDLE_VALUE) { WARN("Could not create cache file: %lu\n", GetLastError()); - heap_free(lpwh->cache_file); + free(lpwh->cache_file); lpwh->cache_file = NULL; } } - heap_free(url); + free(url); } - heap_free(uc.lpszUrlPath); + free(uc.lpszUrlPath); }
hIC = lpwfs->lpAppInfo; @@ -1443,9 +1443,9 @@ HINTERNET WINAPI FtpOpenFileA(HINTERNET hFtpSession, LPWSTR lpwzFileName; HINTERNET ret;
- lpwzFileName = heap_strdupAtoW(lpszFileName); + lpwzFileName = strdupAtoW(lpszFileName); ret = FtpOpenFileW(hFtpSession, lpwzFileName, fdwAccess, dwFlags, dwContext); - heap_free(lpwzFileName); + free(lpwzFileName); return ret; }
@@ -1465,7 +1465,7 @@ static void AsyncFtpOpenFileProc(task_header_t *hdr) TRACE("%p\n", session);
FTP_FtpOpenFileW(session, task->file_name, task->access, task->flags, task->context); - heap_free(task->file_name); + free(task->file_name); }
/*********************************************************************** @@ -1522,7 +1522,7 @@ HINTERNET WINAPI FtpOpenFileW(HINTERNET hFtpSession, open_file_task_t *task;
task = alloc_async_task(&lpwfs->hdr, AsyncFtpOpenFileProc, sizeof(*task)); - task->file_name = heap_strdupW(lpszFileName); + task->file_name = wcsdup(lpszFileName); task->access = fdwAccess; task->flags = dwFlags; task->context = dwContext; @@ -1560,12 +1560,12 @@ BOOL WINAPI FtpGetFileA(HINTERNET hInternet, LPCSTR lpszRemoteFile, LPCSTR lpszN LPWSTR lpwzNewFile; BOOL ret;
- lpwzRemoteFile = heap_strdupAtoW(lpszRemoteFile); - lpwzNewFile = heap_strdupAtoW(lpszNewFile); + lpwzRemoteFile = strdupAtoW(lpszRemoteFile); + lpwzNewFile = strdupAtoW(lpszNewFile); ret = FtpGetFileW(hInternet, lpwzRemoteFile, lpwzNewFile, fFailIfExists, dwLocalFlagsAttribute, dwInternetFlags, dwContext); - heap_free(lpwzRemoteFile); - heap_free(lpwzNewFile); + free(lpwzRemoteFile); + free(lpwzNewFile); return ret; }
@@ -1588,8 +1588,8 @@ static void AsyncFtpGetFileProc(task_header_t *hdr)
FTP_FtpGetFileW(session, task->remote_file, task->new_file, task->fail_if_exists, task->local_attr, task->flags, task->context); - heap_free(task->remote_file); - heap_free(task->new_file); + free(task->remote_file); + free(task->new_file); }
@@ -1648,8 +1648,8 @@ BOOL WINAPI FtpGetFileW(HINTERNET hInternet, LPCWSTR lpszRemoteFile, LPCWSTR lps get_file_task_t *task;
task = alloc_async_task(&lpwfs->hdr, AsyncFtpGetFileProc, sizeof(*task)); - task->remote_file = heap_strdupW(lpszRemoteFile); - task->new_file = heap_strdupW(lpszNewFile); + task->remote_file = wcsdup(lpszRemoteFile); + task->new_file = wcsdup(lpszNewFile); task->local_attr = dwLocalFlagsAttribute; task->fail_if_exists = fFailIfExists; task->flags = dwInternetFlags; @@ -1774,10 +1774,10 @@ BOOL WINAPI FtpDeleteFileA(HINTERNET hFtpSession, LPCSTR lpszFileName) { LPWSTR lpwzFileName; BOOL ret; - - lpwzFileName = heap_strdupAtoW(lpszFileName); + + lpwzFileName = strdupAtoW(lpszFileName); ret = FtpDeleteFileW(hFtpSession, lpwzFileName); - heap_free(lpwzFileName); + free(lpwzFileName); return ret; }
@@ -1794,7 +1794,7 @@ static void AsyncFtpDeleteFileProc(task_header_t *hdr) TRACE("%p\n", session);
FTP_FtpDeleteFileW(session, task->file_name); - heap_free(task->file_name); + free(task->file_name); }
/*********************************************************************** @@ -1844,7 +1844,7 @@ BOOL WINAPI FtpDeleteFileW(HINTERNET hFtpSession, LPCWSTR lpszFileName) delete_file_task_t *task;
task = alloc_async_task(&lpwfs->hdr, AsyncFtpDeleteFileProc, sizeof(*task)); - task->file_name = heap_strdupW(lpszFileName); + task->file_name = wcsdup(lpszFileName);
r = res_to_le(INTERNET_AsyncCall(&task->hdr)); } @@ -1921,10 +1921,10 @@ BOOL WINAPI FtpRemoveDirectoryA(HINTERNET hFtpSession, LPCSTR lpszDirectory) { LPWSTR lpwzDirectory; BOOL ret; - - lpwzDirectory = heap_strdupAtoW(lpszDirectory); + + lpwzDirectory = strdupAtoW(lpszDirectory); ret = FtpRemoveDirectoryW(hFtpSession, lpwzDirectory); - heap_free(lpwzDirectory); + free(lpwzDirectory); return ret; }
@@ -1936,7 +1936,7 @@ static void AsyncFtpRemoveDirectoryProc(task_header_t *hdr) TRACE("%p\n", session);
FTP_FtpRemoveDirectoryW(session, task->directory); - heap_free(task->directory); + free(task->directory); }
/*********************************************************************** @@ -1986,7 +1986,7 @@ BOOL WINAPI FtpRemoveDirectoryW(HINTERNET hFtpSession, LPCWSTR lpszDirectory) directory_task_t *task;
task = alloc_async_task(&lpwfs->hdr, AsyncFtpRemoveDirectoryProc, sizeof(*task)); - task->directory = heap_strdupW(lpszDirectory); + task->directory = wcsdup(lpszDirectory);
r = res_to_le(INTERNET_AsyncCall(&task->hdr)); } @@ -2065,12 +2065,12 @@ BOOL WINAPI FtpRenameFileA(HINTERNET hFtpSession, LPCSTR lpszSrc, LPCSTR lpszDes LPWSTR lpwzSrc; LPWSTR lpwzDest; BOOL ret; - - lpwzSrc = heap_strdupAtoW(lpszSrc); - lpwzDest = heap_strdupAtoW(lpszDest); + + lpwzSrc = strdupAtoW(lpszSrc); + lpwzDest = strdupAtoW(lpszDest); ret = FtpRenameFileW(hFtpSession, lpwzSrc, lpwzDest); - heap_free(lpwzSrc); - heap_free(lpwzDest); + free(lpwzSrc); + free(lpwzDest); return ret; }
@@ -2088,8 +2088,8 @@ static void AsyncFtpRenameFileProc(task_header_t *hdr) TRACE("%p\n", session);
FTP_FtpRenameFileW(session, task->src_file, task->dst_file); - heap_free(task->src_file); - heap_free(task->dst_file); + free(task->src_file); + free(task->dst_file); }
/*********************************************************************** @@ -2139,8 +2139,8 @@ BOOL WINAPI FtpRenameFileW(HINTERNET hFtpSession, LPCWSTR lpszSrc, LPCWSTR lpszD rename_file_task_t *task;
task = alloc_async_task(&lpwfs->hdr, AsyncFtpRenameFileProc, sizeof(*task)); - task->src_file = heap_strdupW(lpszSrc); - task->dst_file = heap_strdupW(lpszDest); + task->src_file = wcsdup(lpszSrc); + task->dst_file = wcsdup(lpszDest);
r = res_to_le(INTERNET_AsyncCall(&task->hdr)); } @@ -2232,7 +2232,7 @@ BOOL WINAPI FtpCommandA( HINTERNET hConnect, BOOL fExpectResponse, DWORD dwFlags return FALSE; }
- if (!(cmdW = heap_strdupAtoW(lpszCommand))) + if (!(cmdW = strdupAtoW(lpszCommand))) { INTERNET_SetLastError(ERROR_OUTOFMEMORY); return FALSE; @@ -2240,7 +2240,7 @@ BOOL WINAPI FtpCommandA( HINTERNET hConnect, BOOL fExpectResponse, DWORD dwFlags
r = FtpCommandW(hConnect, fExpectResponse, dwFlags, cmdW, dwContext, phFtpCommand);
- heap_free(cmdW); + free(cmdW); return r; }
@@ -2291,7 +2291,7 @@ BOOL WINAPI FtpCommandW( HINTERNET hConnect, BOOL fExpectResponse, DWORD dwFlags }
len = WideCharToMultiByte(CP_ACP, 0, lpszCommand, -1, NULL, 0, NULL, NULL) + strlen(szCRLF); - if ((cmd = heap_alloc(len))) + if ((cmd = malloc(len))) WideCharToMultiByte(CP_ACP, 0, lpszCommand, -1, cmd, len, NULL, NULL); else { @@ -2324,7 +2324,7 @@ BOOL WINAPI FtpCommandW( HINTERNET hConnect, BOOL fExpectResponse, DWORD dwFlags
lend: WININET_Release( &lpwfs->hdr ); - heap_free( cmd ); + free(cmd); return r; }
@@ -2342,9 +2342,9 @@ static void FTPSESSION_Destroy(object_header_t *hdr)
WININET_Release(&lpwfs->lpAppInfo->hdr);
- heap_free(lpwfs->lpszPassword); - heap_free(lpwfs->lpszUserName); - heap_free(lpwfs->servername); + free(lpwfs->lpszPassword); + free(lpwfs->lpszUserName); + free(lpwfs->servername); }
static void FTPSESSION_CloseConnection(object_header_t *hdr) @@ -2481,7 +2481,7 @@ HINTERNET FTP_Connect(appinfo_t *hIC, LPCWSTR lpszServerName, WCHAR szPassword[MAX_PATH]; DWORD len = sizeof(szPassword);
- lpwfs->lpszUserName = heap_strdupW(L"anonymous"); + lpwfs->lpszUserName = wcsdup(L"anonymous");
RegOpenKeyW(HKEY_CURRENT_USER, L"Software\Microsoft\Windows\CurrentVersion\Internet Settings", &key); if (RegQueryValueExW(key, L"EmailName", NULL, NULL, (LPBYTE)szPassword, &len)) { @@ -2494,14 +2494,14 @@ HINTERNET FTP_Connect(appinfo_t *hIC, LPCWSTR lpszServerName, RegCloseKey(key);
TRACE("Password used for anonymous ftp : (%s)\n", debugstr_w(szPassword)); - lpwfs->lpszPassword = heap_strdupW(szPassword); + lpwfs->lpszPassword = wcsdup(szPassword); } else { - lpwfs->lpszUserName = heap_strdupW(lpszUserName); - lpwfs->lpszPassword = heap_strdupW(lpszPassword ? lpszPassword : L""); + lpwfs->lpszUserName = wcsdup(lpszUserName); + lpwfs->lpszPassword = wcsdup(lpszPassword ? lpszPassword : L""); } - lpwfs->servername = heap_strdupW(lpszServerName); - + lpwfs->servername = wcsdup(lpszServerName); + /* Don't send a handle created callback if this handle was created with InternetOpenUrl */ if (!(lpwfs->hdr.dwInternalFlags & INET_OPENURL)) { @@ -2703,7 +2703,7 @@ static BOOL FTP_SendCommandA(INT nSocket, FTP_COMMAND ftpCmd, LPCSTR lpszParam,
dwParamLen = lpszParam?strlen(lpszParam)+1:0; len = dwParamLen + strlen(szFtpCommands[ftpCmd]) + strlen(szCRLF); - if (NULL == (buf = heap_alloc(len+1))) + if (NULL == (buf = malloc(len + 1))) { INTERNET_SetLastError(ERROR_OUTOFMEMORY); return FALSE; @@ -2717,7 +2717,7 @@ static BOOL FTP_SendCommandA(INT nSocket, FTP_COMMAND ftpCmd, LPCSTR lpszParam, nRC = sock_send(nSocket, buf+nBytesSent, len - nBytesSent, 0); nBytesSent += nRC; } - heap_free(buf); + free(buf);
if (lpfnStatusCB) { @@ -2743,9 +2743,9 @@ static BOOL FTP_SendCommand(INT nSocket, FTP_COMMAND ftpCmd, LPCWSTR lpszParam, INTERNET_STATUS_CALLBACK lpfnStatusCB, object_header_t *hdr, DWORD_PTR dwContext) { BOOL ret; - LPSTR lpszParamA = heap_strdupWtoA(lpszParam); + char *lpszParamA = strdupWtoA(lpszParam); ret = FTP_SendCommandA(nSocket, ftpCmd, lpszParamA, lpfnStatusCB, hdr, dwContext); - heap_free(lpszParamA); + free(lpszParamA); return ret; }
@@ -3269,7 +3269,7 @@ static BOOL FTP_SendData(ftp_session_t *lpwfs, INT nDataSocket, HANDLE hFile) CHAR *lpszBuffer;
TRACE("\n"); - lpszBuffer = heap_alloc_zero(sizeof(CHAR)*DATA_PACKET_SIZE); + lpszBuffer = calloc(DATA_PACKET_SIZE, 1);
/* Get the size of the file. */ GetFileInformationByHandle(hFile, &fi); @@ -3321,7 +3321,7 @@ static BOOL FTP_SendData(ftp_session_t *lpwfs, INT nDataSocket, HANDLE hFile)
TRACE("file transfer complete!\n");
- heap_free(lpszBuffer); + free(lpszBuffer); return nTotalSent; }
@@ -3390,7 +3390,7 @@ static BOOL FTP_RetrieveFileData(ftp_session_t *lpwfs, INT nDataSocket, HANDLE h
TRACE("\n");
- lpszBuffer = heap_alloc_zero(sizeof(CHAR)*DATA_PACKET_SIZE); + lpszBuffer = calloc(DATA_PACKET_SIZE, 1); if (NULL == lpszBuffer) { INTERNET_SetLastError(ERROR_OUTOFMEMORY); @@ -3412,7 +3412,7 @@ static BOOL FTP_RetrieveFileData(ftp_session_t *lpwfs, INT nDataSocket, HANDLE h TRACE("Data transfer complete\n");
recv_end: - heap_free(lpszBuffer); + free(lpszBuffer); return (nRC != -1); }
@@ -3432,9 +3432,9 @@ static void FTPFINDNEXT_Destroy(object_header_t *hdr)
for (i = 0; i < lpwfn->size; i++) { - heap_free(lpwfn->lpafp[i].lpszName); + free(lpwfn->lpafp[i].lpszName); } - heap_free(lpwfn->lpafp); + free(lpwfn->lpafp); }
static DWORD FTPFINDNEXT_FindNextFileProc(WININETFTPFINDNEXTW *find, LPVOID data) @@ -3699,7 +3699,7 @@ static BOOL FTP_ParseNextFile(INT nSocket, LPCWSTR lpszSearchFile, LPFILEPROPERT
pszToken = strtok(NULL, szSpace); if(!pszToken) continue; - lpfp->lpszName = heap_strdupAtoW(pszToken); + lpfp->lpszName = strdupAtoW(pszToken); TRACE("File: %s\n", debugstr_w(lpfp->lpszName)); } /* NT way of parsing ... : @@ -3748,7 +3748,7 @@ static BOOL FTP_ParseNextFile(INT nSocket, LPCWSTR lpszSearchFile, LPFILEPROPERT
pszToken = strtok(NULL, szSpace); if(!pszToken) continue; - lpfp->lpszName = heap_strdupAtoW(pszToken); + lpfp->lpszName = strdupAtoW(pszToken); TRACE("Name: %s\n", debugstr_w(lpfp->lpszName)); } /* EPLF format - http://cr.yp.to/ftp/list/eplf.html */ @@ -3763,7 +3763,7 @@ static BOOL FTP_ParseNextFile(INT nSocket, LPCWSTR lpszSearchFile, LPFILEPROPERT TRACE("Matched: %s\n", debugstr_w(lpfp->lpszName)); } else { - heap_free(lpfp->lpszName); + free(lpfp->lpszName); lpfp->lpszName = NULL; } } @@ -3790,7 +3790,7 @@ static BOOL FTP_ParseDirectory(ftp_session_t *lpwfs, INT nSocket, LPCWSTR lpszSe TRACE("\n");
/* Allocate initial file properties array */ - *lpafp = heap_alloc_zero(sizeof(FILEPROPERTIESW)*(sizeFilePropArray)); + *lpafp = calloc(sizeFilePropArray, sizeof(FILEPROPERTIESW)); if (!*lpafp) return FALSE;
@@ -3798,16 +3798,17 @@ static BOOL FTP_ParseDirectory(ftp_session_t *lpwfs, INT nSocket, LPCWSTR lpszSe if (indexFilePropArray+1 >= sizeFilePropArray) { LPFILEPROPERTIESW tmpafp; - - sizeFilePropArray *= 2; - tmpafp = heap_realloc_zero(*lpafp, sizeof(FILEPROPERTIESW)*sizeFilePropArray); + + tmpafp = realloc(*lpafp, sizeof(FILEPROPERTIESW) * sizeFilePropArray * 2); if (NULL == tmpafp) { bSuccess = FALSE; break; } + memset(tmpafp + sizeFilePropArray, 0, sizeof(FILEPROPERTIESW) * sizeFilePropArray);
*lpafp = tmpafp; + sizeFilePropArray *= 2; } indexFilePropArray++; } while (FTP_ParseNextFile(nSocket, lpszSearchFile, &(*lpafp)[indexFilePropArray])); @@ -3818,7 +3819,7 @@ static BOOL FTP_ParseDirectory(ftp_session_t *lpwfs, INT nSocket, LPCWSTR lpszSe { LPFILEPROPERTIESW tmpafp;
- tmpafp = heap_realloc(*lpafp, sizeof(FILEPROPERTIESW)*indexFilePropArray); + tmpafp = realloc(*lpafp, sizeof(FILEPROPERTIESW) * indexFilePropArray); if (NULL != tmpafp) *lpafp = tmpafp; } @@ -3826,7 +3827,7 @@ static BOOL FTP_ParseDirectory(ftp_session_t *lpwfs, INT nSocket, LPCWSTR lpszSe } else { - heap_free(*lpafp); + free(*lpafp); INTERNET_SetLastError(ERROR_NO_MORE_FILES); bSuccess = FALSE; } diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c index c9d1c463982..18f61f108fc 100644 --- a/dlls/wininet/http.c +++ b/dlls/wininet/http.c @@ -149,9 +149,9 @@ void server_release(server_t *server)
if(server->cert_chain) CertFreeCertificateChain(server->cert_chain); - heap_free(server->name); - heap_free(server->scheme_host_port); - heap_free(server); + free(server->name); + free(server->scheme_host_port); + free(server); }
static BOOL process_host_port(server_t *server) @@ -162,7 +162,7 @@ static BOOL process_host_port(server_t *server)
name_len = lstrlenW(server->name); len = name_len + 10 /* strlen("://:<port>") */ + ARRAY_SIZE(L"https"); - buf = heap_alloc( len * sizeof(WCHAR) ); + buf = malloc(len * sizeof(WCHAR)); if(!buf) return FALSE;
@@ -194,17 +194,17 @@ server_t *get_server(substr_t name, INTERNET_PORT port, BOOL is_https, BOOL do_c }
if(!server && do_create) { - server = heap_alloc_zero(sizeof(*server)); + server = calloc(1, sizeof(*server)); if(server) { server->ref = 2; /* list reference and return */ server->port = port; server->is_https = is_https; list_init(&server->conn_pool); - server->name = heap_strndupW(name.str, name.len); + server->name = strndupW(name.str, name.len); if(server->name && process_host_port(server)) { list_add_head(&connection_pool, &server->entry); }else { - heap_free(server); + free(server); server = NULL; } } @@ -287,8 +287,8 @@ static WCHAR *get_host_header( http_request_t *req ) WCHAR *ret = NULL;
EnterCriticalSection( &req->headers_section ); - if ((header = HTTP_GetHeader( req, L"Host" ))) ret = heap_strdupW( header->lpszValue ); - else ret = heap_strdupW( req->server->canon_host_port ); + if ((header = HTTP_GetHeader( req, L"Host" ))) ret = wcsdup( header->lpszValue ); + else ret = wcsdup( req->server->canon_host_port ); LeaveCriticalSection( &req->headers_section ); return ret; } @@ -435,7 +435,7 @@ static void gzip_destroy(data_stream_t *stream)
if(!gzip_stream->end_of_data) inflateEnd(&gzip_stream->zstream); - heap_free(gzip_stream); + free(gzip_stream); }
static const data_stream_vtbl_t gzip_stream_vtbl = { @@ -447,12 +447,12 @@ static const data_stream_vtbl_t gzip_stream_vtbl = {
static voidpf wininet_zalloc(voidpf opaque, uInt items, uInt size) { - return heap_alloc(items*size); + return malloc(items * size); }
static void wininet_zfree(voidpf opaque, voidpf address) { - heap_free(address); + free(address); }
static DWORD init_gzip_stream(http_request_t *req, BOOL is_gzip) @@ -460,7 +460,7 @@ static DWORD init_gzip_stream(http_request_t *req, BOOL is_gzip) gzip_stream_t *gzip_stream; int zres;
- gzip_stream = heap_alloc_zero(sizeof(gzip_stream_t)); + gzip_stream = calloc(1, sizeof(gzip_stream_t)); if(!gzip_stream) return ERROR_OUTOFMEMORY;
@@ -471,7 +471,7 @@ static DWORD init_gzip_stream(http_request_t *req, BOOL is_gzip) zres = inflateInit2(&gzip_stream->zstream, is_gzip ? 0x1f : -15); if(zres != Z_OK) { ERR("inflateInit failed: %d\n", zres); - heap_free(gzip_stream); + free(gzip_stream); return ERROR_OUTOFMEMORY; }
@@ -497,15 +497,15 @@ static DWORD init_gzip_stream(http_request_t *req, BOOL is_gzip) static void HTTP_FreeTokens(LPWSTR * token_array) { int i; - for (i = 0; token_array[i]; i++) heap_free(token_array[i]); - heap_free(token_array); + for (i = 0; token_array[i]; i++) free(token_array[i]); + free(token_array); }
static void HTTP_FixURL(http_request_t *request) { /* If we don't have a path we set it to root */ if (NULL == request->path) - request->path = heap_strdupW(L"/"); + request->path = wcsdup(L"/"); else /* remove \r and \n*/ { int nLen = lstrlenW(request->path); @@ -525,10 +525,10 @@ static void HTTP_FixURL(http_request_t *request) request->path, lstrlenW(request->path), L"http://", lstrlenW(L"http://") ) && request->path[0] != '/') /* not an absolute path ?? --> fix it !! */ { - WCHAR *fixurl = heap_alloc((lstrlenW(request->path) + 2)*sizeof(WCHAR)); + WCHAR *fixurl = malloc((wcslen(request->path) + 2) * sizeof(WCHAR)); *fixurl = '/'; lstrcpyW(fixurl + 1, request->path); - heap_free( request->path ); + free(request->path); request->path = fixurl; } } @@ -545,7 +545,7 @@ static WCHAR* build_request_header(http_request_t *request, const WCHAR *verb,
/* allocate space for an array of all the string pointers to be added */ len = request->nCustHeaders * 5 + 10; - if (!(req = heap_alloc( len * sizeof(const WCHAR *) ))) + if (!(req = malloc( len * sizeof(const WCHAR *) ))) { LeaveCriticalSection( &request->headers_section ); return NULL; @@ -585,7 +585,7 @@ static WCHAR* build_request_header(http_request_t *request, const WCHAR *verb, req[n] = NULL;
requestString = HTTP_build_req( req, 4 ); - heap_free( req ); + free( req ); LeaveCriticalSection( &request->headers_section ); return requestString; } @@ -598,7 +598,7 @@ static WCHAR* build_response_header(http_request_t *request, BOOL use_cr)
EnterCriticalSection( &request->headers_section );
- if (!(req = heap_alloc( (request->nCustHeaders * 5 + 8) * sizeof(WCHAR *) ))) + if (!(req = malloc((request->nCustHeaders * 5 + 8) * sizeof(WCHAR *)))) { LeaveCriticalSection( &request->headers_section ); return NULL; @@ -638,7 +638,7 @@ static WCHAR* build_response_header(http_request_t *request, BOOL use_cr) req[n] = NULL;
ret = HTTP_build_req(req, 0); - heap_free(req); + free(req); LeaveCriticalSection( &request->headers_section ); return ret; } @@ -723,7 +723,7 @@ static inline BOOL is_basic_auth_value( LPCWSTR pszAuthValue, LPWSTR *pszRealm ) token++; if (*token == '\0') return TRUE; - *pszRealm = heap_strdupW(token); + *pszRealm = wcsdup(token); strip_spaces(*pszRealm); } } @@ -740,9 +740,9 @@ static void destroy_authinfo( struct HttpAuthInfo *authinfo ) if (SecIsValidHandle(&authinfo->cred)) FreeCredentialsHandle(&authinfo->cred);
- heap_free(authinfo->auth_data); - heap_free(authinfo->scheme); - heap_free(authinfo); + free(authinfo->auth_data); + free(authinfo->scheme); + free(authinfo); }
static UINT retrieve_cached_basic_authorization(http_request_t *req, const WCHAR *host, const WCHAR *realm, char **auth_data) @@ -761,7 +761,7 @@ static UINT retrieve_cached_basic_authorization(http_request_t *req, const WCHAR DWORD length;
TRACE("Authorization found in cache\n"); - *auth_data = heap_alloc(ad->authorizationLen); + *auth_data = malloc(ad->authorizationLen); memcpy(*auth_data,ad->authorization,ad->authorizationLen); rc = ad->authorizationLen;
@@ -769,12 +769,12 @@ static UINT retrieve_cached_basic_authorization(http_request_t *req, const WCHAR colon = strchr(ad->authorization, ':'); length = colon - ad->authorization;
- heap_free(req->session->userName); - heap_free(req->session->password); + free(req->session->userName); + free(req->session->password);
- req->session->userName = heap_strndupAtoW(ad->authorization, length, &length); + req->session->userName = strndupAtoW(ad->authorization, length, &length); length++; - req->session->password = heap_strndupAtoW(&ad->authorization[length], ad->authorizationLen - length, &length); + req->session->password = strndupAtoW(&ad->authorization[length], ad->authorizationLen - length, &length); break; } } @@ -803,17 +803,17 @@ static void cache_basic_authorization(LPWSTR host, LPWSTR realm, LPSTR auth_data if (ad) { TRACE("Found match in cache, replacing\n"); - heap_free(ad->authorization); - ad->authorization = heap_alloc(auth_data_len); + free(ad->authorization); + ad->authorization = malloc(auth_data_len); memcpy(ad->authorization, auth_data, auth_data_len); ad->authorizationLen = auth_data_len; } else { - ad = heap_alloc(sizeof(basicAuthorizationData)); - ad->host = heap_strdupW(host); - ad->realm = heap_strdupW(realm); - ad->authorization = heap_alloc(auth_data_len); + ad = malloc(sizeof(basicAuthorizationData)); + ad->host = wcsdup(host); + ad->realm = wcsdup(realm); + ad->authorization = malloc(auth_data_len); memcpy(ad->authorization, auth_data, auth_data_len); ad->authorizationLen = auth_data_len; list_add_head(&basicAuthorizationCache,&ad->entry); @@ -834,14 +834,14 @@ static BOOL retrieve_cached_authorization(LPWSTR host, LPWSTR scheme, if(!wcsicmp(host, ad->host) && !wcsicmp(scheme, ad->scheme)) { TRACE("Authorization found in cache\n");
- nt_auth_identity->User = heap_strdupW(ad->user); - nt_auth_identity->Password = heap_strdupW(ad->password); - nt_auth_identity->Domain = heap_alloc(sizeof(WCHAR)*ad->domain_len); + nt_auth_identity->User = wcsdup(ad->user); + nt_auth_identity->Password = wcsdup(ad->password); + nt_auth_identity->Domain = malloc(sizeof(WCHAR) * ad->domain_len); if(!nt_auth_identity->User || !nt_auth_identity->Password || (!nt_auth_identity->Domain && ad->domain_len)) { - heap_free(nt_auth_identity->User); - heap_free(nt_auth_identity->Password); - heap_free(nt_auth_identity->Domain); + free(nt_auth_identity->User); + free(nt_auth_identity->Password); + free(nt_auth_identity->Domain); break; }
@@ -875,37 +875,37 @@ static void cache_authorization(LPWSTR host, LPWSTR scheme, }
if(found) { - heap_free(ad->user); - heap_free(ad->password); - heap_free(ad->domain); + free(ad->user); + free(ad->password); + free(ad->domain); } else { - ad = heap_alloc(sizeof(authorizationData)); + ad = malloc(sizeof(authorizationData)); if(!ad) { LeaveCriticalSection(&authcache_cs); return; }
- ad->host = heap_strdupW(host); - ad->scheme = heap_strdupW(scheme); + ad->host = wcsdup(host); + ad->scheme = wcsdup(scheme); list_add_head(&authorizationCache, &ad->entry); }
- ad->user = heap_strndupW(nt_auth_identity->User, nt_auth_identity->UserLength); - ad->password = heap_strndupW(nt_auth_identity->Password, nt_auth_identity->PasswordLength); - ad->domain = heap_strndupW(nt_auth_identity->Domain, nt_auth_identity->DomainLength); + ad->user = strndupW(nt_auth_identity->User, nt_auth_identity->UserLength); + ad->password = strndupW(nt_auth_identity->Password, nt_auth_identity->PasswordLength); + ad->domain = strndupW(nt_auth_identity->Domain, nt_auth_identity->DomainLength); ad->user_len = nt_auth_identity->UserLength; ad->password_len = nt_auth_identity->PasswordLength; ad->domain_len = nt_auth_identity->DomainLength;
if(!ad->host || !ad->scheme || !ad->user || !ad->password || (nt_auth_identity->Domain && !ad->domain)) { - heap_free(ad->host); - heap_free(ad->scheme); - heap_free(ad->user); - heap_free(ad->password); - heap_free(ad->domain); + free(ad->host); + free(ad->scheme); + free(ad->user); + free(ad->password); + free(ad->domain); list_remove(&ad->entry); - heap_free(ad); + free(ad); }
LeaveCriticalSection(&authcache_cs); @@ -920,23 +920,23 @@ void free_authorization_cache(void)
LIST_FOR_EACH_ENTRY_SAFE(basic, basic_safe, &basicAuthorizationCache, basicAuthorizationData, entry) { - heap_free(basic->host); - heap_free(basic->realm); - heap_free(basic->authorization); + free(basic->host); + free(basic->realm); + free(basic->authorization);
list_remove(&basic->entry); - heap_free(basic); + free(basic); }
LIST_FOR_EACH_ENTRY_SAFE(ad, sa_safe, &authorizationCache, authorizationData, entry) { - heap_free(ad->host); - heap_free(ad->scheme); - heap_free(ad->user); - heap_free(ad->password); - heap_free(ad->domain); + free(ad->host); + free(ad->scheme); + free(ad->user); + free(ad->password); + free(ad->domain); list_remove(&ad->entry); - heap_free(ad); + free(ad); }
LeaveCriticalSection(&authcache_cs); @@ -959,7 +959,7 @@ static BOOL HTTP_DoAuthorization( http_request_t *request, LPCWSTR pszAuthValue, TimeStamp exp;
first = TRUE; - pAuthInfo = heap_alloc(sizeof(*pAuthInfo)); + pAuthInfo = malloc(sizeof(*pAuthInfo)); if (!pAuthInfo) return FALSE;
@@ -973,10 +973,10 @@ static BOOL HTTP_DoAuthorization( http_request_t *request, LPCWSTR pszAuthValue,
if (is_basic_auth_value(pszAuthValue,NULL)) { - pAuthInfo->scheme = heap_strdupW(L"Basic"); + pAuthInfo->scheme = wcsdup(L"Basic"); if (!pAuthInfo->scheme) { - heap_free(pAuthInfo); + free(pAuthInfo); return FALSE; } } @@ -985,10 +985,10 @@ static BOOL HTTP_DoAuthorization( http_request_t *request, LPCWSTR pszAuthValue, PVOID pAuthData; SEC_WINNT_AUTH_IDENTITY_W nt_auth_identity;
- pAuthInfo->scheme = heap_strdupW(pszAuthValue); + pAuthInfo->scheme = wcsdup(pszAuthValue); if (!pAuthInfo->scheme) { - heap_free(pAuthInfo); + free(pAuthInfo); return FALSE; }
@@ -1031,9 +1031,9 @@ static BOOL HTTP_DoAuthorization( http_request_t *request, LPCWSTR pszAuthValue, &exp);
if(pAuthData && !domain_and_username) { - heap_free(nt_auth_identity.User); - heap_free(nt_auth_identity.Domain); - heap_free(nt_auth_identity.Password); + free(nt_auth_identity.User); + free(nt_auth_identity.Domain); + free(nt_auth_identity.Password); }
if (sec_status == SEC_E_OK) @@ -1050,8 +1050,8 @@ static BOOL HTTP_DoAuthorization( http_request_t *request, LPCWSTR pszAuthValue, { WARN("AcquireCredentialsHandleW for scheme %s failed with error 0x%08lx\n", debugstr_w(pAuthInfo->scheme), sec_status); - heap_free(pAuthInfo->scheme); - heap_free(pAuthInfo); + free(pAuthInfo->scheme); + free(pAuthInfo); return FALSE; } } @@ -1083,7 +1083,7 @@ static BOOL HTTP_DoAuthorization( http_request_t *request, LPCWSTR pszAuthValue, auth_data_len = retrieve_cached_basic_authorization(request, host, szRealm,&auth_data); if (auth_data_len == 0) { - heap_free(szRealm); + free(szRealm); return FALSE; } } @@ -1093,10 +1093,10 @@ static BOOL HTTP_DoAuthorization( http_request_t *request, LPCWSTR pszAuthValue, passlen = WideCharToMultiByte(CP_UTF8, 0, password, lstrlenW(password), NULL, 0, NULL, NULL);
/* length includes a nul terminator, which will be re-used for the ':' */ - auth_data = heap_alloc(userlen + 1 + passlen); + auth_data = malloc(userlen + 1 + passlen); if (!auth_data) { - heap_free(szRealm); + free(szRealm); return FALSE; }
@@ -1111,7 +1111,7 @@ static BOOL HTTP_DoAuthorization( http_request_t *request, LPCWSTR pszAuthValue, pAuthInfo->auth_data = auth_data; pAuthInfo->auth_data_len = auth_data_len; pAuthInfo->finished = TRUE; - heap_free(szRealm); + free(szRealm); return TRUE; } else @@ -1136,11 +1136,11 @@ static BOOL HTTP_DoAuthorization( http_request_t *request, LPCWSTR pszAuthValue, { pszAuthData++; in.cbBuffer = HTTP_DecodeBase64(pszAuthData, NULL); - in.pvBuffer = heap_alloc(in.cbBuffer); + in.pvBuffer = malloc(in.cbBuffer); HTTP_DecodeBase64(pszAuthData, in.pvBuffer); }
- buffer = heap_alloc(pAuthInfo->max_token); + buffer = malloc(pAuthInfo->max_token);
out.BufferType = SECBUFFER_TOKEN; out.cbBuffer = pAuthInfo->max_token; @@ -1173,7 +1173,7 @@ static BOOL HTTP_DoAuthorization( http_request_t *request, LPCWSTR pszAuthValue, else { ERR("InitializeSecurityContextW returned error 0x%08lx\n", sec_status); - heap_free(out.pvBuffer); + free(out.pvBuffer); destroy_authinfo(pAuthInfo); *ppAuthInfo = NULL; return FALSE; @@ -1200,7 +1200,7 @@ static DWORD HTTP_HttpAddRequestHeadersW(http_request_t *request, len = lstrlenW(lpszHeader); else len = dwHeaderLength; - buffer = heap_alloc(sizeof(WCHAR)*(len+1)); + buffer = malloc(sizeof(WCHAR) * (len + 1)); lstrcpynW( buffer, lpszHeader, len + 1);
lpszStart = buffer; @@ -1245,7 +1245,7 @@ static DWORD HTTP_HttpAddRequestHeadersW(http_request_t *request, lpszStart = lpszEnd; } while (res == ERROR_SUCCESS);
- heap_free(buffer); + free(buffer); return res; }
@@ -1306,11 +1306,11 @@ BOOL WINAPI HttpAddRequestHeadersA(HINTERNET hHttpRequest, TRACE("%p, %s, %lu, %08lx\n", hHttpRequest, debugstr_an(lpszHeader, dwHeaderLength), dwHeaderLength, dwModifier);
if(lpszHeader) - headers = heap_strndupAtoW(lpszHeader, dwHeaderLength, &dwHeaderLength); + headers = strndupAtoW(lpszHeader, dwHeaderLength, &dwHeaderLength);
r = HttpAddRequestHeadersW(hHttpRequest, headers, dwHeaderLength, dwModifier);
- heap_free(headers); + free(headers); return r; }
@@ -1321,10 +1321,10 @@ static void free_accept_types( WCHAR **accept_types ) if (!types) return; while ((ptr = *types)) { - heap_free( ptr ); + free(ptr); types++; } - heap_free( accept_types ); + free(accept_types); }
static WCHAR **convert_accept_types( const char **accept_types ) @@ -1356,12 +1356,12 @@ static WCHAR **convert_accept_types( const char **accept_types ) types++; } if (invalid_pointer) return NULL; - if (!(typesW = heap_alloc( sizeof(WCHAR *) * (count + 1) ))) return NULL; + if (!(typesW = malloc(sizeof(WCHAR *) * (count + 1)))) return NULL; count = 0; types = accept_types; while (*types) { - if (*types && **types) typesW[count++] = heap_strdupAtoW( *types ); + if (*types && **types) typesW[count++] = strdupAtoW(*types); types++; } typesW[count] = NULL; @@ -1394,28 +1394,28 @@ HINTERNET WINAPI HttpOpenRequestA(HINTERNET hHttpSession,
if (lpszVerb) { - szVerb = heap_strdupAtoW(lpszVerb); + szVerb = strdupAtoW(lpszVerb); if ( !szVerb ) goto end; }
if (lpszObjectName) { - szObjectName = heap_strdupAtoW(lpszObjectName); + szObjectName = strdupAtoW(lpszObjectName); if ( !szObjectName ) goto end; }
if (lpszVersion) { - szVersion = heap_strdupAtoW(lpszVersion); + szVersion = strdupAtoW(lpszVersion); if ( !szVersion ) goto end; }
if (lpszReferrer) { - szReferrer = heap_strdupAtoW(lpszReferrer); + szReferrer = strdupAtoW(lpszReferrer); if ( !szReferrer ) goto end; } @@ -1426,10 +1426,10 @@ HINTERNET WINAPI HttpOpenRequestA(HINTERNET hHttpSession,
end: free_accept_types(szAcceptTypes); - heap_free(szReferrer); - heap_free(szVersion); - heap_free(szObjectName); - heap_free(szVerb); + free(szReferrer); + free(szVersion); + free(szObjectName); + free(szVerb); return rc; }
@@ -1549,7 +1549,7 @@ static WCHAR *encode_auth_data( const WCHAR *scheme, const char *data, UINT data
/* scheme + space + base64 encoded data (3/2/1 bytes data -> 4 bytes of characters) */ len = scheme_len + 1 + ((data_len + 2) * 4) / 3; - if (!(ret = heap_alloc( (len + 1) * sizeof(WCHAR) ))) return NULL; + if (!(ret = malloc( (len + 1) * sizeof(WCHAR) ))) return NULL; memcpy( ret, scheme, scheme_len * sizeof(WCHAR) ); ret[scheme_len] = ' '; HTTP_EncodeBase64( data, data_len, ret + scheme_len + 1 ); @@ -1578,7 +1578,7 @@ static BOOL HTTP_InsertAuthorization( http_request_t *request, struct HttpAuthIn * connection tracking */ if (wcsicmp(pAuthInfo->scheme, L"Basic")) { - heap_free(pAuthInfo->auth_data); + free(pAuthInfo->auth_data); pAuthInfo->auth_data = NULL; pAuthInfo->auth_data_len = 0; } @@ -1588,7 +1588,7 @@ static BOOL HTTP_InsertAuthorization( http_request_t *request, struct HttpAuthIn
HTTP_ProcessHeader(request, header, authorization, HTTP_ADDHDR_FLAG_REQ | HTTP_ADDREQ_FLAG_REPLACE | HTTP_ADDREQ_FLAG_ADD); - heap_free(authorization); + free(authorization); } else { @@ -1608,8 +1608,8 @@ static BOOL HTTP_InsertAuthorization( http_request_t *request, struct HttpAuthIn
if (!(authorization = encode_auth_data(L"Basic", data, data_len))) { - heap_free(data); - heap_free(host); + free(data); + free(host); return FALSE; }
@@ -1617,10 +1617,10 @@ static BOOL HTTP_InsertAuthorization( http_request_t *request, struct HttpAuthIn
HTTP_ProcessHeader(request, header, authorization, HTTP_ADDHDR_FLAG_REQ | HTTP_ADDREQ_FLAG_REPLACE | HTTP_ADDREQ_FLAG_ADD); - heap_free(data); - heap_free(authorization); + free(data); + free(authorization); } - heap_free(host); + free(host); } return TRUE; } @@ -1634,7 +1634,7 @@ static WCHAR *build_proxy_path_url(http_request_t *req) size = len + lstrlenW(req->path) + 1; if(*req->path != '/') size++; - url = heap_alloc(size * sizeof(WCHAR)); + url = malloc(size * sizeof(WCHAR)); if(!url) return NULL;
@@ -1728,14 +1728,14 @@ static BOOL HTTP_DealWithProxy(appinfo_t *hIC, http_session_t *session, http_req return FALSE; if(CSTR_EQUAL != CompareStringW(LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE, proxy, lstrlenW(L"http://"), L"http://", lstrlenW(L"http://"))) { - WCHAR *proxy_url = heap_alloc(lstrlenW(proxy)*sizeof(WCHAR) + sizeof(L"http://")); + WCHAR *proxy_url = malloc(wcslen(proxy) * sizeof(WCHAR) + sizeof(L"http://")); if(!proxy_url) { - heap_free(proxy); + free(proxy); return FALSE; } lstrcpyW(proxy_url, L"http://"); lstrcatW(proxy_url, proxy); - heap_free(proxy); + free(proxy); proxy = proxy_url; }
@@ -1747,7 +1747,7 @@ static BOOL HTTP_DealWithProxy(appinfo_t *hIC, http_session_t *session, http_req new_server = get_server(substr(UrlComponents.lpszHostName, UrlComponents.dwHostNameLength), UrlComponents.nPort, UrlComponents.nScheme == INTERNET_SCHEME_HTTPS, TRUE); } - heap_free(proxy); + free(proxy); if(!new_server) return FALSE;
@@ -1797,7 +1797,7 @@ static WCHAR *compose_request_url(http_request_t *req) scheme = L"http://";
len = lstrlenW(scheme) + lstrlenW(host) + (req->path[0] != '/' ? 1 : 0) + lstrlenW(req->path); - ptr = buf = heap_alloc((len+1) * sizeof(WCHAR)); + ptr = buf = malloc((len + 1) * sizeof(WCHAR)); if(buf) { lstrcpyW(ptr, scheme); ptr += lstrlenW(ptr); @@ -1849,18 +1849,18 @@ static void HTTPREQ_Destroy(object_header_t *hdr) if(request->proxy) server_release(request->proxy);
- heap_free(request->path); - heap_free(request->verb); - heap_free(request->version); - heap_free(request->statusText); + free(request->path); + free(request->verb); + free(request->version); + free(request->statusText);
for (i = 0; i < request->nCustHeaders; i++) { - heap_free(request->custHeaders[i].lpszField); - heap_free(request->custHeaders[i].lpszValue); + free(request->custHeaders[i].lpszField); + free(request->custHeaders[i].lpszValue); } destroy_data_stream(request->data_stream); - heap_free(request->custHeaders); + free(request->custHeaders); }
static void http_release_netconn(http_request_t *req, BOOL reuse) @@ -2088,7 +2088,7 @@ static DWORD HTTPREQ_QueryOption(object_header_t *hdr, DWORD option, void *buffe return ERROR_OUTOFMEMORY;
res = str_to_buffer(url, buffer, size, unicode); - heap_free(url); + free(url); return res; } case INTERNET_OPTION_USER_AGENT: @@ -2124,7 +2124,7 @@ static DWORD HTTPREQ_QueryOption(object_header_t *hdr, DWORD option, void *buffe error = GetLastError(); if (!ret && error == ERROR_INSUFFICIENT_BUFFER) { - if (!(info = heap_alloc(nbytes))) + if (!(info = malloc(nbytes))) return ERROR_OUTOFMEMORY;
GetUrlCacheEntryInfoW(req->req_file->url, info, &nbytes); @@ -2132,7 +2132,7 @@ static DWORD HTTPREQ_QueryOption(object_header_t *hdr, DWORD option, void *buffe ts->ftExpires = info->ExpireTime; ts->ftLastModified = info->LastModifiedTime;
- heap_free(info); + free(info); *size = sizeof(*ts); return ERROR_SUCCESS; } @@ -2378,23 +2378,23 @@ static DWORD HTTPREQ_SetOption(object_header_t *hdr, DWORD option, void *buffer, return ERROR_SUCCESS;
case INTERNET_OPTION_USERNAME: - heap_free(req->session->userName); - if (!(req->session->userName = heap_strdupW(buffer))) return ERROR_OUTOFMEMORY; + free(req->session->userName); + if (!(req->session->userName = wcsdup(buffer))) return ERROR_OUTOFMEMORY; return ERROR_SUCCESS;
case INTERNET_OPTION_PASSWORD: - heap_free(req->session->password); - if (!(req->session->password = heap_strdupW(buffer))) return ERROR_OUTOFMEMORY; + free(req->session->password); + if (!(req->session->password = wcsdup(buffer))) return ERROR_OUTOFMEMORY; return ERROR_SUCCESS;
case INTERNET_OPTION_PROXY_USERNAME: - heap_free(req->session->appInfo->proxyUsername); - if (!(req->session->appInfo->proxyUsername = heap_strdupW(buffer))) return ERROR_OUTOFMEMORY; + free(req->session->appInfo->proxyUsername); + if (!(req->session->appInfo->proxyUsername = wcsdup(buffer))) return ERROR_OUTOFMEMORY; return ERROR_SUCCESS;
case INTERNET_OPTION_PROXY_PASSWORD: - heap_free(req->session->appInfo->proxyPassword); - if (!(req->session->appInfo->proxyPassword = heap_strdupW(buffer))) return ERROR_OUTOFMEMORY; + free(req->session->appInfo->proxyPassword); + if (!(req->session->appInfo->proxyPassword = wcsdup(buffer))) return ERROR_OUTOFMEMORY; return ERROR_SUCCESS;
} @@ -2422,7 +2422,7 @@ static void commit_cache_entry(http_request_t *req) req->req_file->is_committed = TRUE; else WARN("CommitUrlCacheEntry failed: %lu\n", GetLastError()); - heap_free(header); + free(header); }
static void create_cache_entry(http_request_t *req) @@ -2908,7 +2908,7 @@ static DWORD chunked_drain_content(data_stream_t *stream, http_request_t *req, B static void chunked_destroy(data_stream_t *stream) { chunked_stream_t *chunked_stream = (chunked_stream_t*)stream; - heap_free(chunked_stream); + free(chunked_stream); }
static const data_stream_vtbl_t chunked_stream_vtbl = { @@ -2951,7 +2951,7 @@ static DWORD set_content_length(http_request_t *request) { chunked_stream_t *chunked_stream;
- chunked_stream = heap_alloc(sizeof(*chunked_stream)); + chunked_stream = malloc(sizeof(*chunked_stream)); if(!chunked_stream) return ERROR_OUTOFMEMORY;
@@ -3396,7 +3396,7 @@ static DWORD HTTP_HttpOpenRequestW(http_session_t *session, rc = UrlCanonicalizeW(lpszObjectName, &dummy, &len, URL_ESCAPE_SPACES_ONLY); if (rc != E_POINTER) len = lstrlenW(lpszObjectName)+1; - request->path = heap_alloc(len*sizeof(WCHAR)); + request->path = malloc(len * sizeof(WCHAR)); rc = UrlCanonicalizeW(lpszObjectName, request->path, &len, URL_ESCAPE_SPACES_ONLY); if (rc != S_OK) @@ -3405,7 +3405,7 @@ static DWORD HTTP_HttpOpenRequestW(http_session_t *session, lstrcpyW(request->path,lpszObjectName); } }else { - request->path = heap_strdupW(L"/"); + request->path = wcsdup(L"/"); }
if (lpszReferrer && *lpszReferrer) @@ -3424,8 +3424,8 @@ static DWORD HTTP_HttpOpenRequestW(http_session_t *session, } }
- request->verb = heap_strdupW(lpszVerb && *lpszVerb ? lpszVerb : L"GET"); - request->version = heap_strdupW(lpszVersion && *lpszVersion ? lpszVersion : L"HTTP/1.1"); + request->verb = wcsdup(lpszVerb && *lpszVerb ? lpszVerb : L"GET"); + request->version = wcsdup(lpszVersion && *lpszVersion ? lpszVersion : L"HTTP/1.1");
if (hIC->proxy && hIC->proxy[0] && !HTTP_ShouldBypassProxy(hIC, session->hostName)) HTTP_DealWithProxy( hIC, session, request ); @@ -3625,7 +3625,7 @@ static DWORD HTTP_HttpQueryInfoW(http_request_t *request, DWORD dwInfoLevel, } *lpdwBufferLength = len;
- heap_free(headers); + free(headers); LeaveCriticalSection( &request->headers_section ); return res; } @@ -3649,7 +3649,7 @@ static DWORD HTTP_HttpQueryInfoW(http_request_t *request, DWORD dwInfoLevel, if (len > *lpdwBufferLength) { *lpdwBufferLength = len; - heap_free(headers); + free(headers); LeaveCriticalSection( &request->headers_section ); return ERROR_INSUFFICIENT_BUFFER; } @@ -3669,7 +3669,7 @@ static DWORD HTTP_HttpQueryInfoW(http_request_t *request, DWORD dwInfoLevel, } *lpdwBufferLength = len - sizeof(WCHAR);
- heap_free(headers); + free(headers); LeaveCriticalSection( &request->headers_section ); return ERROR_SUCCESS; } @@ -4027,7 +4027,7 @@ BOOL WINAPI HttpQueryInfoA(HINTERNET hHttpRequest, DWORD dwInfoLevel, } else alloclen = len; - bufferW = heap_alloc(alloclen); + bufferW = malloc( alloclen ); /* buffer is in/out because of HTTP_QUERY_CUSTOM */ if ((dwInfoLevel & HTTP_QUERY_HEADER_MASK) == HTTP_QUERY_CUSTOM) MultiByteToWideChar( CP_ACP, 0, lpBuffer, -1, bufferW, alloclen / sizeof(WCHAR) ); @@ -4053,7 +4053,7 @@ BOOL WINAPI HttpQueryInfoA(HINTERNET hHttpRequest, DWORD dwInfoLevel, * the Unicode characters can be reduced to a single byte */ *lpdwBufferLength = len / sizeof(WCHAR);
- heap_free( bufferW ); + free( bufferW ); return result; }
@@ -4070,11 +4070,11 @@ static WCHAR *get_redirect_url(http_request_t *request) url_length = 0; res = HTTP_HttpQueryInfoW(request, HTTP_QUERY_LOCATION, redirect_url, &url_length, NULL); if(res == ERROR_INSUFFICIENT_BUFFER) { - redirect_url = heap_alloc(url_length); + redirect_url = malloc(url_length); res = HTTP_HttpQueryInfoW(request, HTTP_QUERY_LOCATION, redirect_url, &url_length, NULL); } if(res != ERROR_SUCCESS) { - heap_free(redirect_url); + free(redirect_url); return NULL; }
@@ -4095,7 +4095,7 @@ static WCHAR *get_redirect_url(http_request_t *request)
b = InternetCreateUrlW(&urlComponents, 0, NULL, &url_length); if(!b && GetLastError() == ERROR_INSUFFICIENT_BUFFER) { - orig_url = heap_alloc(url_length); + orig_url = malloc(url_length);
/* convert from bytes to characters */ url_length = url_length / sizeof(WCHAR) - 1; @@ -4106,17 +4106,17 @@ static WCHAR *get_redirect_url(http_request_t *request) url_length = 0; b = InternetCombineUrlW(orig_url, redirect_url, NULL, &url_length, ICU_ENCODE_SPACES_ONLY); if(!b && GetLastError() == ERROR_INSUFFICIENT_BUFFER) { - combined_url = heap_alloc(url_length * sizeof(WCHAR)); + combined_url = malloc(url_length * sizeof(WCHAR)); b = InternetCombineUrlW(orig_url, redirect_url, combined_url, &url_length, ICU_ENCODE_SPACES_ONLY); if(!b) { - heap_free(combined_url); + free(combined_url); combined_url = NULL; } } }
- heap_free(orig_url); - heap_free(redirect_url); + free(orig_url); + free(redirect_url); return combined_url; }
@@ -4173,15 +4173,15 @@ static DWORD HTTP_HandleRedirect(http_request_t *request, WCHAR *url) custom_port = urlComponents.nPort != INTERNET_DEFAULT_HTTPS_PORT; }
- heap_free(session->hostName); + free(session->hostName);
- session->hostName = heap_strndupW(urlComponents.lpszHostName, urlComponents.dwHostNameLength); + session->hostName = strndupW(urlComponents.lpszHostName, urlComponents.dwHostNameLength); session->hostPort = urlComponents.nPort;
- heap_free(session->userName); + free(session->userName); session->userName = NULL; if (urlComponents.dwUserNameLength) - session->userName = heap_strndupW(urlComponents.lpszUserName, urlComponents.dwUserNameLength); + session->userName = strndupW(urlComponents.lpszUserName, urlComponents.dwUserNameLength);
reset_data_stream(request);
@@ -4204,7 +4204,7 @@ static DWORD HTTP_HandleRedirect(http_request_t *request, WCHAR *url) HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE | HTTP_ADDHDR_FLAG_REQ); }
- heap_free(request->path); + free(request->path); request->path = NULL; if(urlComponents.dwUrlPathLength) { @@ -4213,11 +4213,11 @@ static DWORD HTTP_HandleRedirect(http_request_t *request, WCHAR *url) WCHAR dummy[] = L""; WCHAR *path;
- path = heap_strndupW(urlComponents.lpszUrlPath, urlComponents.dwUrlPathLength); + path = strndupW(urlComponents.lpszUrlPath, urlComponents.dwUrlPathLength); rc = UrlEscapeW(path, dummy, &needed, URL_ESCAPE_SPACES_ONLY); if (rc != E_POINTER) ERR("Unable to escape string!(%s) (%ld)\n",debugstr_w(path),rc); - request->path = heap_alloc(needed*sizeof(WCHAR)); + request->path = malloc(needed * sizeof(WCHAR)); rc = UrlEscapeW(path, request->path, &needed, URL_ESCAPE_SPACES_ONLY); if (rc != S_OK) @@ -4225,7 +4225,7 @@ static DWORD HTTP_HandleRedirect(http_request_t *request, WCHAR *url) ERR("Unable to escape string!(%s) (%ld)\n",debugstr_w(path),rc); lstrcpyW(request->path, path); } - heap_free(path); + free(path); }
/* Remove custom content-type/length headers on redirects. */ @@ -4249,7 +4249,7 @@ static LPWSTR HTTP_build_req( LPCWSTR *list, int len ) len += lstrlenW( *t ); len++;
- str = heap_alloc(len*sizeof(WCHAR)); + str = malloc(len * sizeof(WCHAR)); *str = 0;
for( t = list; *t ; t++ ) @@ -4269,7 +4269,7 @@ static void HTTP_InsertCookies(http_request_t *request)
HTTP_HttpAddRequestHeadersW(request, cookies, lstrlenW(cookies), HTTP_ADDREQ_FLAG_REPLACE | HTTP_ADDREQ_FLAG_ADD); - heap_free(cookies); + free(cookies); }
static WORD HTTP_ParseWkday(LPCWSTR day) @@ -4865,7 +4865,7 @@ static char *build_ascii_request( const WCHAR *str, void *data, DWORD data_len, int len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL ); char *ret;
- if (!(ret = heap_alloc( len + data_len ))) return NULL; + if (!(ret = malloc( len + data_len ))) return NULL; WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL ); if (data_len) memcpy( ret + len - 1, data, data_len ); *out_len = len + data_len - 1; @@ -4906,7 +4906,7 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders,
/* if the verb is NULL default to GET */ if (!request->verb) - request->verb = heap_strdupW(L"GET"); + request->verb = wcsdup(L"GET");
HTTP_ProcessHeader(request, L"Host", request->server->canon_host_port, HTTP_ADDREQ_FLAG_ADD_IF_NEW | HTTP_ADDHDR_FLAG_REQ); @@ -4922,11 +4922,11 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders, int len;
len = lstrlenW(request->session->appInfo->agent) + lstrlenW(L"User-Agent: %s\r\n"); - agent_header = heap_alloc(len * sizeof(WCHAR)); + agent_header = malloc(len * sizeof(WCHAR)); swprintf(agent_header, len, L"User-Agent: %s\r\n", request->session->appInfo->agent);
HTTP_HttpAddRequestHeadersW(request, agent_header, lstrlenW(agent_header), HTTP_ADDREQ_FLAG_ADD_IF_NEW); - heap_free(agent_header); + free(agent_header); } if (request->hdr.dwFlags & INTERNET_FLAG_PRAGMA_NOCACHE) { @@ -5009,7 +5009,7 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders, { WCHAR *url = build_proxy_path_url(request); request_header = build_request_header(request, request->verb, url, request->version, TRUE); - heap_free(url); + free(url); } else { @@ -5026,7 +5026,7 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders, data_len = 0;
ascii_req = build_ascii_request(request_header, lpOptional, data_len, &len); - heap_free(request_header); + free(request_header); TRACE("full request -> %s\n", debugstr_a(ascii_req) );
INTERNET_SendCallback(&request->hdr, request->hdr.dwContext, @@ -5034,7 +5034,7 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders,
NETCON_set_timeout( request->netconn, TRUE, request->send_timeout ); res = NETCON_send(request->netconn, ascii_req, len, 0, &cnt); - heap_free( ascii_req ); + free(ascii_req); if(res != ERROR_SUCCESS) { TRACE("send failed: %lu\n", res); if(!reusing_connection) @@ -5103,12 +5103,12 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders, if (wcscmp(request->verb, L"GET") && wcscmp(request->verb, L"HEAD") && request->status_code != HTTP_STATUS_REDIRECT_KEEP_VERB) { - heap_free(request->verb); - request->verb = heap_strdupW(L"GET"); + free(request->verb); + request->verb = wcsdup(L"GET"); } http_release_netconn(request, drain_content(request, FALSE) == ERROR_SUCCESS); res = HTTP_HandleRedirect(request, new_url); - heap_free(new_url); + free(new_url); if (res == ERROR_SUCCESS) loop_next = TRUE; redirected = TRUE; @@ -5120,7 +5120,7 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders, dwBufferSize=2048; if (request->status_code == HTTP_STATUS_DENIED) { - WCHAR *host = heap_strdupW( request->server->canon_host_port ); + WCHAR *host = wcsdup(request->server->canon_host_port); DWORD dwIndex = 0; while (HTTP_HttpQueryInfoW(request,HTTP_QUERY_WWW_AUTHENTICATE,szAuthValue,&dwBufferSize,&dwIndex) == ERROR_SUCCESS) { @@ -5140,7 +5140,7 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders,
dwBufferSize = 2048; } - heap_free( host ); + free(host);
if(!loop_next) { TRACE("Cleaning wrong authorization data\n"); @@ -5250,7 +5250,7 @@ static void AsyncHttpSendRequestProc(task_header_t *hdr) HTTP_HttpSendRequestW(request, task->headers, task->headers_len, task->optional, task->optional_len, task->content_len, task->end_request);
- heap_free(task->headers); + free(task->headers); }
@@ -5301,12 +5301,12 @@ static DWORD HTTP_HttpEndRequestW(http_request_t *request, DWORD dwFlags, DWORD_ if (wcscmp(request->verb, L"GET") && wcscmp(request->verb, L"HEAD") && request->status_code != HTTP_STATUS_REDIRECT_KEEP_VERB) { - heap_free(request->verb); - request->verb = heap_strdupW(L"GET"); + free(request->verb); + request->verb = wcsdup(L"GET"); } http_release_netconn(request, drain_content(request, FALSE) == ERROR_SUCCESS); res = HTTP_HandleRedirect(request, new_url); - heap_free(new_url); + free(new_url); if (res == ERROR_SUCCESS) res = HTTP_HttpSendRequestW(request, NULL, 0, NULL, 0, 0, TRUE); } @@ -5450,7 +5450,7 @@ BOOL WINAPI HttpSendRequestExA(HINTERNET hRequest, { headerlen = MultiByteToWideChar(CP_ACP,0,lpBuffersIn->lpcszHeader, lpBuffersIn->dwHeadersLength,0,0); - header = heap_alloc(headerlen*sizeof(WCHAR)); + header = malloc(headerlen * sizeof(WCHAR)); if (!(BuffersInW.lpcszHeader = header)) { SetLastError(ERROR_OUTOFMEMORY); @@ -5471,7 +5471,7 @@ BOOL WINAPI HttpSendRequestExA(HINTERNET hRequest,
rc = HttpSendRequestExW(hRequest, lpBuffersIn ? &BuffersInW : NULL, NULL, dwFlags, dwContext);
- heap_free(header); + free(header); return rc; }
@@ -5527,7 +5527,7 @@ BOOL WINAPI HttpSendRequestExW(HINTERNET hRequest, else size = lpBuffersIn->dwHeadersLength * sizeof(WCHAR);
- task->headers = heap_alloc(size); + task->headers = malloc(size); memcpy(task->headers, lpBuffersIn->lpcszHeader, size); } else task->headers = NULL; @@ -5624,7 +5624,7 @@ BOOL WINAPI HttpSendRequestW(HINTERNET hHttpRequest, LPCWSTR lpszHeaders, if (dwHeaderLength == ~0u) size = (lstrlenW(lpszHeaders) + 1) * sizeof(WCHAR); else size = dwHeaderLength * sizeof(WCHAR);
- task->headers = heap_alloc(size); + task->headers = malloc(size); memcpy(task->headers, lpszHeaders, size); } else @@ -5671,11 +5671,11 @@ BOOL WINAPI HttpSendRequestA(HINTERNET hHttpRequest, LPCSTR lpszHeaders, if(lpszHeaders!=NULL) { nLen=MultiByteToWideChar(CP_ACP,0,lpszHeaders,dwHeaderLength,NULL,0); - szHeaders = heap_alloc(nLen*sizeof(WCHAR)); + szHeaders = malloc(nLen * sizeof(WCHAR)); MultiByteToWideChar(CP_ACP,0,lpszHeaders,dwHeaderLength,szHeaders,nLen); } result = HttpSendRequestW(hHttpRequest, szHeaders, nLen, lpOptional, dwOptionalLength); - heap_free(szHeaders); + free(szHeaders); return result; }
@@ -5693,9 +5693,9 @@ static void HTTPSESSION_Destroy(object_header_t *hdr)
WININET_Release(&session->appInfo->hdr);
- heap_free(session->hostName); - heap_free(session->password); - heap_free(session->userName); + free(session->hostName); + free(session->password); + free(session->userName); }
static DWORD HTTPSESSION_QueryOption(object_header_t *hdr, DWORD option, void *buffer, DWORD *size, BOOL unicode) @@ -5753,26 +5753,26 @@ static DWORD HTTPSESSION_SetOption(object_header_t *hdr, DWORD option, void *buf switch(option) { case INTERNET_OPTION_USERNAME: { - heap_free(ses->userName); - if (!(ses->userName = heap_strdupW(buffer))) return ERROR_OUTOFMEMORY; + free(ses->userName); + if (!(ses->userName = wcsdup(buffer))) return ERROR_OUTOFMEMORY; return ERROR_SUCCESS; } case INTERNET_OPTION_PASSWORD: { - heap_free(ses->password); - if (!(ses->password = heap_strdupW(buffer))) return ERROR_OUTOFMEMORY; + free(ses->password); + if (!(ses->password = wcsdup(buffer))) return ERROR_OUTOFMEMORY; return ERROR_SUCCESS; } case INTERNET_OPTION_PROXY_USERNAME: { - heap_free(ses->appInfo->proxyUsername); - if (!(ses->appInfo->proxyUsername = heap_strdupW(buffer))) return ERROR_OUTOFMEMORY; + free(ses->appInfo->proxyUsername); + if (!(ses->appInfo->proxyUsername = wcsdup(buffer))) return ERROR_OUTOFMEMORY; return ERROR_SUCCESS; } case INTERNET_OPTION_PROXY_PASSWORD: { - heap_free(ses->appInfo->proxyPassword); - if (!(ses->appInfo->proxyPassword = heap_strdupW(buffer))) return ERROR_OUTOFMEMORY; + free(ses->appInfo->proxyPassword); + if (!(ses->appInfo->proxyPassword = wcsdup(buffer))) return ERROR_OUTOFMEMORY; return ERROR_SUCCESS; } case INTERNET_OPTION_CONNECT_TIMEOUT: @@ -5853,10 +5853,10 @@ DWORD HTTP_Connect(appinfo_t *hIC, LPCWSTR lpszServerName, session->appInfo = hIC; list_add_head( &hIC->hdr.children, &session->hdr.entry );
- session->hostName = heap_strdupW(lpszServerName); + session->hostName = wcsdup(lpszServerName); if (lpszUserName && lpszUserName[0]) - session->userName = heap_strdupW(lpszUserName); - session->password = heap_strdupW(lpszPassword); + session->userName = wcsdup(lpszUserName); + session->password = wcsdup(lpszPassword); session->hostPort = serverPort; session->connect_timeout = hIC->connect_timeout; session->send_timeout = 0; @@ -5974,12 +5974,12 @@ static DWORD HTTP_GetResponseHeaders(http_request_t *request, INT *len) { WARN("No status line at head of response (%s)\n", debugstr_w(buffer));
- heap_free(request->version); - heap_free(request->statusText); + free(request->version); + free(request->statusText);
request->status_code = HTTP_STATUS_OK; - request->version = heap_strdupW(L"HTTP/1.0"); - request->statusText = heap_strdupW(L"OK"); + request->version = wcsdup(L"HTTP/1.0"); + request->statusText = wcsdup(L"OK");
goto lend; } @@ -5989,11 +5989,11 @@ static DWORD HTTP_GetResponseHeaders(http_request_t *request, INT *len) HTTP_ProcessHeader(request, L"Status", status_code, HTTP_ADDREQ_FLAG_REPLACE | HTTP_ADDREQ_FLAG_ADD);
- heap_free(request->version); - heap_free(request->statusText); + free(request->version); + free(request->statusText);
- request->version = heap_strdupW(buffer); - request->statusText = heap_strdupW(status_text ? status_text : L""); + request->version = wcsdup(buffer); + request->statusText = wcsdup(status_text ? status_text : L"");
/* Restore the spaces */ *(status_code-1) = ' '; @@ -6054,7 +6054,7 @@ static LPWSTR * HTTP_InterpretHttpHeader(LPCWSTR buffer) LPWSTR pszColon; INT len;
- pTokenPair = heap_alloc_zero(sizeof(*pTokenPair)*3); + pTokenPair = calloc(3, sizeof(*pTokenPair));
pszColon = wcschr(buffer, ':'); /* must have two tokens */ @@ -6066,7 +6066,7 @@ static LPWSTR * HTTP_InterpretHttpHeader(LPCWSTR buffer) return NULL; }
- pTokenPair[0] = heap_alloc((pszColon - buffer + 1) * sizeof(WCHAR)); + pTokenPair[0] = malloc((pszColon - buffer + 1) * sizeof(WCHAR)); if (!pTokenPair[0]) { HTTP_FreeTokens(pTokenPair); @@ -6078,7 +6078,7 @@ static LPWSTR * HTTP_InterpretHttpHeader(LPCWSTR buffer) /* skip colon */ pszColon++; len = lstrlenW(pszColon); - pTokenPair[1] = heap_alloc((len + 1) * sizeof(WCHAR)); + pTokenPair[1] = malloc((len + 1) * sizeof(WCHAR)); if (!pTokenPair[1]) { HTTP_FreeTokens(pTokenPair); @@ -6202,7 +6202,7 @@ static DWORD HTTP_ProcessHeader(http_request_t *request, LPCWSTR field, LPCWSTR
len = origlen + valuelen + ((ch > 0) ? 2 : 0);
- lpsztmp = heap_realloc(lphttpHdr->lpszValue, (len+1)*sizeof(WCHAR)); + lpsztmp = realloc(lphttpHdr->lpszValue, (len + 1) * sizeof(WCHAR)); if (lpsztmp) { lphttpHdr->lpszValue = lpsztmp; @@ -6221,7 +6221,7 @@ static DWORD HTTP_ProcessHeader(http_request_t *request, LPCWSTR field, LPCWSTR } else { - WARN("heap_realloc (%d bytes) failed\n",len+1); + WARN("realloc (%d bytes) failed\n",len+1); res = ERROR_OUTOFMEMORY; } } @@ -6281,16 +6281,21 @@ static DWORD HTTP_InsertCustomHeader(http_request_t *request, LPHTTPHEADERW lpHd TRACE("--> %s: %s\n", debugstr_w(lpHdr->lpszField), debugstr_w(lpHdr->lpszValue)); count = request->nCustHeaders + 1; if (count > 1) - lph = heap_realloc_zero(request->custHeaders, sizeof(HTTPHEADERW) * count); + { + lph = realloc(request->custHeaders, sizeof(HTTPHEADERW) * count); + memset(lph + request->nCustHeaders, 0, sizeof(HTTPHEADERW)); + } else - lph = heap_alloc_zero(sizeof(HTTPHEADERW) * count); + { + lph = calloc(count, sizeof(HTTPHEADERW)); + }
if (!lph) return ERROR_OUTOFMEMORY;
request->custHeaders = lph; - request->custHeaders[count-1].lpszField = heap_strdupW(lpHdr->lpszField); - request->custHeaders[count-1].lpszValue = heap_strdupW(lpHdr->lpszValue); + request->custHeaders[count-1].lpszField = wcsdup(lpHdr->lpszField); + request->custHeaders[count-1].lpszValue = wcsdup(lpHdr->lpszValue); request->custHeaders[count-1].wFlags = lpHdr->wFlags; request->custHeaders[count-1].wCount= lpHdr->wCount; request->nCustHeaders++; @@ -6314,8 +6319,8 @@ static BOOL HTTP_DeleteCustomHeader(http_request_t *request, DWORD index) return FALSE; request->nCustHeaders--;
- heap_free(request->custHeaders[index].lpszField); - heap_free(request->custHeaders[index].lpszValue); + free(request->custHeaders[index].lpszField); + free(request->custHeaders[index].lpszValue);
memmove( &request->custHeaders[index], &request->custHeaders[index+1], (request->nCustHeaders - index)* sizeof(HTTPHEADERW) ); diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c index 292fd44dd8e..26d262b9665 100644 --- a/dlls/wininet/internet.c +++ b/dlls/wininet/internet.c @@ -101,7 +101,7 @@ void *alloc_object(object_header_t *parent, const object_vtbl_t *vtbl, size_t si object_header_t **p; BOOL res = TRUE;
- ret = heap_alloc_zero(size); + ret = calloc(1, size); if(!ret) return NULL;
@@ -111,7 +111,7 @@ void *alloc_object(object_header_t *parent, const object_vtbl_t *vtbl, size_t si
if(!handle_table_size) { num = 16; - p = heap_alloc_zero(sizeof(handle_table[0]) * num); + p = calloc(num, sizeof(handle_table[0])); if(p) { handle_table = p; handle_table_size = num; @@ -121,8 +121,9 @@ void *alloc_object(object_header_t *parent, const object_vtbl_t *vtbl, size_t si } }else if(next_handle == handle_table_size) { num = handle_table_size * 2; - p = heap_realloc_zero(handle_table, sizeof(handle_table[0]) * num); + p = realloc(handle_table, sizeof(handle_table[0]) * num); if(p) { + memset(p + handle_table_size, 0, sizeof(handle_table[0]) * handle_table_size); handle_table = p; handle_table_size = num; }else { @@ -144,7 +145,7 @@ void *alloc_object(object_header_t *parent, const object_vtbl_t *vtbl, size_t si LeaveCriticalSection( &WININET_cs );
if(!res) { - heap_free(ret); + free(ret); return NULL; }
@@ -239,7 +240,7 @@ BOOL WININET_Release( object_header_t *info ) LeaveCriticalSection( &WININET_cs ); }
- heap_free(info); + free(info); } return TRUE; } @@ -284,7 +285,7 @@ BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) case DLL_THREAD_DETACH: if (g_dwTlsErrIndex != TLS_OUT_OF_INDEXES) { - heap_free(TlsGetValue(g_dwTlsErrIndex)); + free(TlsGetValue(g_dwTlsErrIndex)); } break;
@@ -297,7 +298,7 @@ BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
if (g_dwTlsErrIndex != TLS_OUT_OF_INDEXES) { - heap_free(TlsGetValue(g_dwTlsErrIndex)); + free(TlsGetValue(g_dwTlsErrIndex)); TlsFree(g_dwTlsErrIndex); } break; @@ -393,7 +394,7 @@ WCHAR *INTERNET_FindProxyForProtocol(LPCWSTR szProxy, LPCWSTR proto) equal - ptr == lstrlenW(proto) && !wcsnicmp(proto, ptr, lstrlenW(proto))) { - ret = heap_strndupW(equal + 1, end - equal - 1); + ret = strndupW(equal + 1, end - equal - 1); TRACE("found proxy for %s: %s\n", debugstr_w(proto), debugstr_w(ret)); return ret; } @@ -412,7 +413,7 @@ WCHAR *INTERNET_FindProxyForProtocol(LPCWSTR szProxy, LPCWSTR proto) end = ptr + lstrlenW(ptr); if (!wcschr(ptr, '=')) { - ret = heap_strndupW(ptr, end - ptr); + ret = strndupW(ptr, end - ptr); TRACE("found proxy for %s: %s\n", debugstr_w(proto), debugstr_w(ret)); return ret; } @@ -463,10 +464,10 @@ BOOL WINAPI DetectAutoProxyUrl(LPSTR lpszAutoProxyUrl,
static void FreeProxyInfo( proxyinfo_t *lpwpi ) { - heap_free(lpwpi->proxy); - heap_free(lpwpi->proxyBypass); - heap_free(lpwpi->proxyUsername); - heap_free(lpwpi->proxyPassword); + free(lpwpi->proxy); + free(lpwpi->proxyBypass); + free(lpwpi->proxyUsername); + free(lpwpi->proxyPassword); }
static proxyinfo_t *global_proxy; @@ -477,7 +478,7 @@ static void free_global_proxy( void ) if (global_proxy) { FreeProxyInfo( global_proxy ); - heap_free( global_proxy ); + free( global_proxy ); } LeaveCriticalSection( &WININET_cs ); } @@ -493,25 +494,25 @@ static BOOL parse_proxy_url( proxyinfo_t *info, const WCHAR *url ) if (!InternetCrackUrlW( url, 0, 0, &uc )) return FALSE; if (!uc.dwHostNameLength) { - if (!(info->proxy = heap_strdupW( url ))) return FALSE; + if (!(info->proxy = wcsdup( url ))) return FALSE; info->proxyUsername = NULL; info->proxyPassword = NULL; return TRUE; } - if (!(info->proxy = heap_alloc( (uc.dwHostNameLength + 12) * sizeof(WCHAR) ))) return FALSE; + if (!(info->proxy = malloc( (uc.dwHostNameLength + 12) * sizeof(WCHAR) ))) return FALSE; swprintf( info->proxy, uc.dwHostNameLength + 12, L"%.*s:%u", uc.dwHostNameLength, uc.lpszHostName, uc.nPort );
if (!uc.dwUserNameLength) info->proxyUsername = NULL; - else if (!(info->proxyUsername = heap_strndupW( uc.lpszUserName, uc.dwUserNameLength ))) + else if (!(info->proxyUsername = strndupW( uc.lpszUserName, uc.dwUserNameLength ))) { - heap_free( info->proxy ); + free( info->proxy ); return FALSE; } if (!uc.dwPasswordLength) info->proxyPassword = NULL; - else if (!(info->proxyPassword = heap_strndupW( uc.lpszPassword, uc.dwPasswordLength ))) + else if (!(info->proxyPassword = strndupW( uc.lpszPassword, uc.dwPasswordLength ))) { - heap_free( info->proxyUsername ); - heap_free( info->proxy ); + free( info->proxyUsername ); + free( info->proxy ); return FALSE; } return TRUE; @@ -542,8 +543,8 @@ static LONG INTERNET_LoadProxySettings( proxyinfo_t *lpwpi ) if (global_proxy) { lpwpi->proxyEnabled = global_proxy->proxyEnabled; - lpwpi->proxy = heap_strdupW( global_proxy->proxy ); - lpwpi->proxyBypass = heap_strdupW( global_proxy->proxyBypass ); + lpwpi->proxy = wcsdup( global_proxy->proxy ); + lpwpi->proxyBypass = wcsdup( global_proxy->proxyBypass ); } LeaveCriticalSection( &WININET_cs );
@@ -572,7 +573,7 @@ static LONG INTERNET_LoadProxySettings( proxyinfo_t *lpwpi ) { LPWSTR szProxy, p;
- if (!(szProxy = heap_alloc(len))) + if (!(szProxy = malloc( len ))) { RegCloseKey( key ); FreeProxyInfo( lpwpi ); @@ -633,21 +634,21 @@ static LONG INTERNET_LoadProxySettings( proxyinfo_t *lpwpi ) { LPWSTR szProxy;
- if (!(szProxy = heap_alloc(len))) + if (!(szProxy = malloc( len ))) { RegCloseKey( key ); return ERROR_OUTOFMEMORY; } RegQueryValueExW( key, L"ProxyOverride", NULL, &type, (BYTE*)szProxy, &len );
- heap_free( lpwpi->proxyBypass ); + free( lpwpi->proxyBypass ); lpwpi->proxyBypass = szProxy;
TRACE("http proxy bypass (from registry) = %s\n", debugstr_w(lpwpi->proxyBypass)); } else { - heap_free( lpwpi->proxyBypass ); + free( lpwpi->proxyBypass ); lpwpi->proxyBypass = NULL;
TRACE("No proxy bypass server settings in registry.\n"); @@ -657,14 +658,14 @@ static LONG INTERNET_LoadProxySettings( proxyinfo_t *lpwpi ) { WCHAR *envproxyW;
- if (!(envproxyW = heap_alloc(lstrlenW(envproxy) * sizeof(WCHAR)))) + if (!(envproxyW = malloc( wcslen(envproxy) * sizeof(WCHAR) ))) { RegCloseKey( key ); return ERROR_OUTOFMEMORY; } lstrcpyW( envproxyW, envproxy );
- heap_free( lpwpi->proxyBypass ); + free( lpwpi->proxyBypass ); lpwpi->proxyBypass = envproxyW;
TRACE("http proxy bypass (from environment) = %s\n", debugstr_w(lpwpi->proxyBypass)); @@ -772,11 +773,11 @@ static VOID APPINFO_Destroy(object_header_t *hdr)
TRACE("%p\n",lpwai);
- heap_free(lpwai->agent); - heap_free(lpwai->proxy); - heap_free(lpwai->proxyBypass); - heap_free(lpwai->proxyUsername); - heap_free(lpwai->proxyPassword); + free(lpwai->agent); + free(lpwai->proxy); + free(lpwai->proxyBypass); + free(lpwai->proxyUsername); + free(lpwai->proxyPassword); }
static DWORD APPINFO_QueryOption(object_header_t *hdr, DWORD option, void *buffer, DWORD *size, BOOL unicode) @@ -938,8 +939,8 @@ static DWORD APPINFO_SetOption(object_header_t *hdr, DWORD option, void *buf, DW ai->connect_timeout = *(ULONG*)buf; return ERROR_SUCCESS; case INTERNET_OPTION_USER_AGENT: - heap_free(ai->agent); - if (!(ai->agent = heap_strdupW(buf))) return ERROR_OUTOFMEMORY; + free(ai->agent); + if (!(ai->agent = wcsdup(buf))) return ERROR_OUTOFMEMORY; return ERROR_SUCCESS; case INTERNET_OPTION_REFRESH: FIXME("INTERNET_OPTION_REFRESH\n"); @@ -1021,12 +1022,12 @@ HINTERNET WINAPI InternetOpenW(LPCWSTR lpszAgent, DWORD dwAccessType, lpwai->proxyPassword = NULL; lpwai->connect_timeout = connect_timeout;
- lpwai->agent = heap_strdupW(lpszAgent); + lpwai->agent = wcsdup(lpszAgent); if(dwAccessType == INTERNET_OPEN_TYPE_PRECONFIG) INTERNET_ConfigureProxy( lpwai ); else if(dwAccessType == INTERNET_OPEN_TYPE_PROXY) { - lpwai->proxy = heap_strdupW(lpszProxy); - lpwai->proxyBypass = heap_strdupW(lpszProxyBypass); + lpwai->proxy = wcsdup(lpszProxy); + lpwai->proxyBypass = wcsdup(lpszProxyBypass); }
TRACE("returning %p\n", lpwai); @@ -1054,15 +1055,15 @@ HINTERNET WINAPI InternetOpenA(LPCSTR lpszAgent, DWORD dwAccessType, TRACE("(%s, 0x%08lx, %s, %s, 0x%08lx)\n", debugstr_a(lpszAgent), dwAccessType, debugstr_a(lpszProxy), debugstr_a(lpszProxyBypass), dwFlags);
- szAgent = heap_strdupAtoW(lpszAgent); - szProxy = heap_strdupAtoW(lpszProxy); - szBypass = heap_strdupAtoW(lpszProxyBypass); + szAgent = strdupAtoW(lpszAgent); + szProxy = strdupAtoW(lpszProxy); + szBypass = strdupAtoW(lpszProxyBypass);
rc = InternetOpenW(szAgent, dwAccessType, szProxy, szBypass, dwFlags);
- heap_free(szAgent); - heap_free(szProxy); - heap_free(szBypass); + free(szAgent); + free(szProxy); + free(szBypass); return rc; }
@@ -1224,8 +1225,8 @@ BOOL WINAPI InternetGetConnectedStateExW(LPDWORD lpdwStatus, LPWSTR lpszConnecti
if (errcode == ERROR_SUCCESS) break; - heap_free(buf); - if (errcode == ERROR_BUFFER_OVERFLOW && !(buf = heap_alloc(size))) + free(buf); + if (errcode == ERROR_BUFFER_OVERFLOW && !(buf = malloc(size))) errcode = ERROR_NOT_ENOUGH_MEMORY; if (errcode != ERROR_BUFFER_OVERFLOW) { @@ -1255,7 +1256,7 @@ BOOL WINAPI InternetGetConnectedStateExW(LPDWORD lpdwStatus, LPWSTR lpszConnecti break; } } - heap_free(buf); + free(buf);
if (lpdwStatus) *lpdwStatus = status;
@@ -1289,7 +1290,7 @@ BOOL WINAPI InternetGetConnectedStateExA(LPDWORD lpdwStatus, LPSTR lpszConnectio TRACE("(%p, %p, %ld, 0x%08lx)\n", lpdwStatus, lpszConnectionName, dwNameLen, dwReserved);
if (lpszConnectionName && dwNameLen > 0) - lpwszConnectionName = heap_alloc(dwNameLen * sizeof(WCHAR)); + lpwszConnectionName = malloc(dwNameLen * sizeof(WCHAR));
rc = InternetGetConnectedStateExW(lpdwStatus,lpwszConnectionName, dwNameLen, dwReserved); @@ -1297,7 +1298,7 @@ BOOL WINAPI InternetGetConnectedStateExA(LPDWORD lpdwStatus, LPSTR lpszConnectio WideCharToMultiByte(CP_ACP,0,lpwszConnectionName,-1,lpszConnectionName, dwNameLen, NULL, NULL);
- heap_free(lpwszConnectionName); + free(lpwszConnectionName); return rc; }
@@ -1385,16 +1386,16 @@ HINTERNET WINAPI InternetConnectA(HINTERNET hInternet, LPWSTR szUserName; LPWSTR szPassword;
- szServerName = heap_strdupAtoW(lpszServerName); - szUserName = heap_strdupAtoW(lpszUserName); - szPassword = heap_strdupAtoW(lpszPassword); + szServerName = strdupAtoW(lpszServerName); + szUserName = strdupAtoW(lpszUserName); + szPassword = strdupAtoW(lpszPassword);
rc = InternetConnectW(hInternet, szServerName, nServerPort, szUserName, szPassword, dwService, dwFlags, dwContext);
- heap_free(szServerName); - heap_free(szUserName); - heap_free(szPassword); + free(szServerName); + free(szUserName); + free(szPassword); return rc; }
@@ -1547,7 +1548,7 @@ static BOOL set_url_component_AtoW(const char *comp_a, DWORD len_a, WCHAR **comp return TRUE; }
- if(!(*comp_w = *buf = heap_alloc(len_a*sizeof(WCHAR)))) { + if(!(*comp_w = *buf = malloc(len_a * sizeof(WCHAR)))) { SetLastError(ERROR_OUTOFMEMORY); return FALSE; } @@ -1589,7 +1590,7 @@ BOOL WINAPI InternetCrackUrlA(const char *url, DWORD url_length, DWORD flags, UR && set_url_component_AtoW(ret_comp->lpszExtraInfo, ret_comp->dwExtraInfoLength, &comp.lpszExtraInfo, &comp.dwExtraInfoLength, &extra);
- if(ret && !(url_w = heap_strndupAtoW(url, url_length ? url_length : -1, &url_length))) { + if(ret && !(url_w = strndupAtoW(url, url_length ? url_length : -1, &url_length))) { SetLastError(ERROR_OUTOFMEMORY); ret = FALSE; } @@ -1619,13 +1620,13 @@ BOOL WINAPI InternetCrackUrlA(const char *url, DWORD url_length, DWORD flags, UR debugstr_an(ret_comp->lpszExtraInfo, ret_comp->dwExtraInfoLength)); }
- heap_free(host); - heap_free(user); - heap_free(pass); - heap_free(path); - heap_free(scheme); - heap_free(extra); - heap_free(url_w); + free(host); + free(user); + free(pass); + free(path); + free(scheme); + free(extra); + free(url_w); return ret; }
@@ -1714,7 +1715,7 @@ BOOL WINAPI InternetCrackUrlW(const WCHAR *lpszUrl, DWORD dwUrlLength, DWORD dwF DWORD len = dwUrlLength + 1; BOOL ret;
- if (!(url_tmp = heap_strndupW(lpszUrl, dwUrlLength))) + if (!(url_tmp = strndupW(lpszUrl, dwUrlLength))) { SetLastError(ERROR_OUTOFMEMORY); return FALSE; @@ -1724,11 +1725,11 @@ BOOL WINAPI InternetCrackUrlW(const WCHAR *lpszUrl, DWORD dwUrlLength, DWORD dwF ret = InternetCanonicalizeUrlW(url_tmp, buffer, &len, ICU_DECODE | ICU_NO_ENCODE); if (!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER) { - buffer = heap_alloc(len * sizeof(WCHAR)); + buffer = malloc(len * sizeof(WCHAR)); if (!buffer) { SetLastError(ERROR_OUTOFMEMORY); - heap_free(url_tmp); + free(url_tmp); return FALSE; } ret = InternetCanonicalizeUrlW(url_tmp, buffer, &len, ICU_DECODE | ICU_NO_ENCODE); @@ -1736,8 +1737,8 @@ BOOL WINAPI InternetCrackUrlW(const WCHAR *lpszUrl, DWORD dwUrlLength, DWORD dwF if (ret) ret = InternetCrackUrlW(buffer, len, dwFlags & ~ICU_DECODE, lpUC);
- if (buffer != url_tmp) heap_free(buffer); - heap_free(url_tmp); + if (buffer != url_tmp) free(buffer); + free(url_tmp); return ret; } lpszap = lpszUrl; @@ -2347,16 +2348,16 @@ static IP_ADAPTER_ADDRESSES *get_adapters(void) GAA_FLAG_SKIP_DNS_SERVER | GAA_FLAG_SKIP_FRIENDLY_NAME; IP_ADAPTER_ADDRESSES *tmp, *ret;
- if (!(ret = heap_alloc( size ))) return NULL; + if (!(ret = malloc( size ))) return NULL; err = GetAdaptersAddresses( AF_UNSPEC, flags, NULL, ret, &size ); while (err == ERROR_BUFFER_OVERFLOW) { - if (!(tmp = heap_realloc( ret, size ))) break; + if (!(tmp = realloc( ret, size ))) break; ret = tmp; err = GetAdaptersAddresses( AF_UNSPEC, flags, NULL, ret, &size ); } if (err == ERROR_SUCCESS) return ret; - heap_free( ret ); + free( ret ); return NULL; }
@@ -2386,12 +2387,12 @@ static WCHAR *detect_proxy_autoconfig_url_dhcp(void) /* FIXME: also skip adapters where DHCP is disabled */
size = 256; - if (!(buf = heap_alloc( size ))) goto done; + if (!(buf = malloc( size ))) goto done; err = DhcpRequestParams( DHCPCAPI_REQUEST_SYNCHRONOUS, NULL, name, NULL, send_params, recv_params, buf, &size, NULL ); while (err == ERROR_MORE_DATA) { - if (!(tmp = heap_realloc( buf, size ))) goto done; + if (!(tmp = realloc( buf, size ))) goto done; buf = tmp; err = DhcpRequestParams( DHCPCAPI_REQUEST_SYNCHRONOUS, NULL, name, NULL, send_params, recv_params, buf, &size, NULL ); @@ -2399,7 +2400,7 @@ static WCHAR *detect_proxy_autoconfig_url_dhcp(void) if (err == ERROR_SUCCESS && param.nBytesData) { int len = MultiByteToWideChar( CP_ACP, 0, (const char *)param.Data, param.nBytesData, NULL, 0 ); - if ((ret = heap_alloc( (len + 1) * sizeof(WCHAR) ))) + if ((ret = malloc( (len + 1) * sizeof(WCHAR) ))) { MultiByteToWideChar( CP_ACP, 0, (const char *)param.Data, param.nBytesData, ret, len ); ret[len] = 0; @@ -2410,8 +2411,8 @@ static WCHAR *detect_proxy_autoconfig_url_dhcp(void) }
done: - heap_free( buf ); - heap_free( adapters ); + free( buf ); + free( adapters ); return ret; }
@@ -2422,10 +2423,10 @@ static char *get_computer_name( COMPUTER_NAME_FORMAT format )
GetComputerNameExA( format, NULL, &size ); if (GetLastError() != ERROR_MORE_DATA) return NULL; - if (!(ret = heap_alloc( size ))) return NULL; + if (!(ret = malloc( size ))) return NULL; if (!GetComputerNameExA( format, ret, &size )) { - heap_free( ret ); + free( ret ); return NULL; } return ret; @@ -2473,7 +2474,7 @@ static WCHAR *detect_proxy_autoconfig_url_dns(void) if (!(fqdn = get_computer_name( ComputerNamePhysicalDnsFullyQualified ))) return NULL; if (!(domain = get_computer_name( ComputerNamePhysicalDnsDomain ))) { - heap_free( fqdn ); + free( fqdn ); return NULL; } p = fqdn; @@ -2483,10 +2484,10 @@ static WCHAR *detect_proxy_autoconfig_url_dns(void) struct addrinfo *ai, hints; int res;
- if (!(name = heap_alloc( sizeof("wpad") + strlen(p) ))) + if (!(name = malloc( sizeof("wpad") + strlen(p) ))) { - heap_free( fqdn ); - heap_free( domain ); + free( fqdn ); + free( domain ); return NULL; } strcpy( name, "wpad" ); @@ -2502,15 +2503,15 @@ static WCHAR *detect_proxy_autoconfig_url_dns(void) if (ret) { TRACE("returning %s\n", debugstr_w(ret)); - heap_free( name ); + free( name ); break; } } - heap_free( name ); + free( name ); p++; } - heap_free( domain ); - heap_free( fqdn ); + free( domain ); + free( fqdn ); return ret; }
@@ -2641,25 +2642,25 @@ static DWORD query_global_option(DWORD option, void *buffer, DWORD *size, BOOL u
case INTERNET_PER_CONN_PROXY_SERVER: if (unicode) - optionW->Value.pszValue = heap_strdupW(pi.proxy); + optionW->Value.pszValue = wcsdup(pi.proxy); else - optionA->Value.pszValue = heap_strdupWtoA(pi.proxy); + optionA->Value.pszValue = strdupWtoA(pi.proxy); break;
case INTERNET_PER_CONN_PROXY_BYPASS: if (unicode) - optionW->Value.pszValue = heap_strdupW(pi.proxyBypass); + optionW->Value.pszValue = wcsdup(pi.proxyBypass); else - optionA->Value.pszValue = heap_strdupWtoA(pi.proxyBypass); + optionA->Value.pszValue = strdupWtoA(pi.proxyBypass); break;
case INTERNET_PER_CONN_AUTOCONFIG_URL: if (!url) optionW->Value.pszValue = NULL; else if (unicode) - optionW->Value.pszValue = heap_strdupW(url); + optionW->Value.pszValue = wcsdup(url); else - optionA->Value.pszValue = heap_strdupWtoA(url); + optionA->Value.pszValue = strdupWtoA(url); break;
case INTERNET_PER_CONN_AUTODISCOVERY_FLAGS: @@ -2680,7 +2681,7 @@ static DWORD query_global_option(DWORD option, void *buffer, DWORD *size, BOOL u break; } } - heap_free(url); + free(url); FreeProxyInfo(&pi);
return res; @@ -2955,14 +2956,14 @@ BOOL WINAPI InternetSetOptionW(HINTERNET hInternet, DWORD dwOption, { EnterCriticalSection( &WININET_cs ); free_global_proxy(); - global_proxy = heap_alloc( sizeof(proxyinfo_t) ); + global_proxy = malloc(sizeof(proxyinfo_t)); if (global_proxy) { if (info->dwAccessType == INTERNET_OPEN_TYPE_PROXY) { global_proxy->proxyEnabled = 1; - global_proxy->proxy = heap_strdupW( info->lpszProxy ); - global_proxy->proxyBypass = heap_strdupW( info->lpszProxyBypass ); + global_proxy->proxy = wcsdup(info->lpszProxy); + global_proxy->proxyBypass = wcsdup(info->lpszProxyBypass); } else { @@ -3117,8 +3118,8 @@ BOOL WINAPI InternetSetOptionW(HINTERNET hInternet, DWORD dwOption,
switch (option->dwOption) { case INTERNET_PER_CONN_PROXY_SERVER: - heap_free(pi.proxy); - pi.proxy = heap_strdupW(option->Value.pszValue); + free(pi.proxy); + pi.proxy = wcsdup(option->Value.pszValue); break;
case INTERNET_PER_CONN_FLAGS: @@ -3133,8 +3134,8 @@ BOOL WINAPI InternetSetOptionW(HINTERNET hInternet, DWORD dwOption, break;
case INTERNET_PER_CONN_PROXY_BYPASS: - heap_free(pi.proxyBypass); - pi.proxyBypass = heap_strdupW(option->Value.pszValue); + free(pi.proxyBypass); + pi.proxyBypass = wcsdup(option->Value.pszValue); break;
case INTERNET_PER_CONN_AUTOCONFIG_URL: @@ -3204,7 +3205,7 @@ BOOL WINAPI InternetSetOptionA(HINTERNET hInternet, DWORD dwOption, proxlen = MultiByteToWideChar( CP_ACP, 0, pi->lpszProxy, -1, NULL, 0); prbylen= MultiByteToWideChar( CP_ACP, 0, pi->lpszProxyBypass, -1, NULL, 0); wlen = sizeof(*piw) + proxlen + prbylen; - wbuffer = heap_alloc(wlen*sizeof(WCHAR) ); + wbuffer = malloc( wlen * sizeof(WCHAR) ); piw = (LPINTERNET_PROXY_INFOW) wbuffer; piw->dwAccessType = pi->dwAccessType; prox = (LPWSTR) &piw[1]; @@ -3221,7 +3222,7 @@ BOOL WINAPI InternetSetOptionA(HINTERNET hInternet, DWORD dwOption, case INTERNET_OPTION_PROXY_USERNAME: case INTERNET_OPTION_PROXY_PASSWORD: wlen = MultiByteToWideChar( CP_ACP, 0, lpBuffer, -1, NULL, 0 ); - if (!(wbuffer = heap_alloc( wlen * sizeof(WCHAR) ))) return ERROR_OUTOFMEMORY; + if (!(wbuffer = malloc( wlen * sizeof(WCHAR) ))) return ERROR_OUTOFMEMORY; MultiByteToWideChar( CP_ACP, 0, lpBuffer, -1, wbuffer, wlen ); break; case INTERNET_OPTION_PER_CONNECTION_OPTION: { @@ -3229,21 +3230,21 @@ BOOL WINAPI InternetSetOptionA(HINTERNET hInternet, DWORD dwOption, INTERNET_PER_CONN_OPTION_LISTW *listW; INTERNET_PER_CONN_OPTION_LISTA *listA = lpBuffer; wlen = sizeof(INTERNET_PER_CONN_OPTION_LISTW); - wbuffer = heap_alloc(wlen); + wbuffer = malloc( wlen ); listW = wbuffer;
listW->dwSize = sizeof(INTERNET_PER_CONN_OPTION_LISTW); if (listA->pszConnection) { wlen = MultiByteToWideChar( CP_ACP, 0, listA->pszConnection, -1, NULL, 0 ); - listW->pszConnection = heap_alloc(wlen*sizeof(WCHAR)); + listW->pszConnection = malloc( wlen * sizeof(WCHAR) ); MultiByteToWideChar( CP_ACP, 0, listA->pszConnection, -1, listW->pszConnection, wlen ); } else listW->pszConnection = NULL; listW->dwOptionCount = listA->dwOptionCount; listW->dwOptionError = listA->dwOptionError; - listW->pOptions = heap_alloc(sizeof(INTERNET_PER_CONN_OPTIONW) * listA->dwOptionCount); + listW->pOptions = malloc( sizeof(INTERNET_PER_CONN_OPTIONW) * listA->dwOptionCount );
for (i = 0; i < listA->dwOptionCount; ++i) { INTERNET_PER_CONN_OPTIONA *optA = listA->pOptions + i; @@ -3260,7 +3261,7 @@ BOOL WINAPI InternetSetOptionA(HINTERNET hInternet, DWORD dwOption, if (optA->Value.pszValue) { wlen = MultiByteToWideChar( CP_ACP, 0, optA->Value.pszValue, -1, NULL, 0 ); - optW->Value.pszValue = heap_alloc(wlen*sizeof(WCHAR)); + optW->Value.pszValue = malloc( wlen * sizeof(WCHAR) ); MultiByteToWideChar( CP_ACP, 0, optA->Value.pszValue, -1, optW->Value.pszValue, wlen ); } else @@ -3303,15 +3304,15 @@ BOOL WINAPI InternetSetOptionA(HINTERNET hInternet, DWORD dwOption, case INTERNET_PER_CONN_PROXY_SERVER: case INTERNET_PER_CONN_AUTOCONFIG_SECONDARY_URL: case INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_URL: - heap_free( opt->Value.pszValue ); + free( opt->Value.pszValue ); break; default: break; } } - heap_free( list->pOptions ); + free( list->pOptions ); } - heap_free( wbuffer ); + free( wbuffer ); }
return r; @@ -3425,11 +3426,11 @@ BOOL WINAPI InternetTimeToSystemTimeA( LPCSTR string, SYSTEMTIME* time, DWORD re
TRACE( "%s %p 0x%08lx\n", debugstr_a(string), time, reserved );
- stringW = heap_strdupAtoW(string); + stringW = strdupAtoW( string ); if (stringW) { ret = InternetTimeToSystemTimeW( stringW, time, reserved ); - heap_free( stringW ); + free( stringW ); } return ret; } @@ -3594,12 +3595,12 @@ BOOL WINAPI InternetCheckConnectionW( LPCWSTR lpszUrl, DWORD dwFlags, DWORD dwRe int fd; BOOL b;
- host_z = heap_strndupW(host, host_len); + host_z = strndupW(host, host_len); if (!host_z) return FALSE;
b = GetAddress(host_z, port, (struct sockaddr *)&saddr, &sa_len, NULL); - heap_free(host_z); + free(host_z); if(!b) goto End; init_winsock(); @@ -3619,7 +3620,7 @@ BOOL WINAPI InternetCheckConnectionW( LPCWSTR lpszUrl, DWORD dwFlags, DWORD dwRe char *command;
len = WideCharToMultiByte(CP_UNIXCP, 0, host, host_len, NULL, 0, NULL, NULL); - command = heap_alloc(strlen(ping)+len+strlen(redirect)+1); + command = malloc(strlen(ping) + len + strlen(redirect) + 1); strcpy(command, ping); WideCharToMultiByte(CP_UNIXCP, 0, host, host_len, command+sizeof(ping)-1, len, NULL, NULL); strcpy(command+sizeof(ping)-1+len, redirect); @@ -3627,7 +3628,7 @@ BOOL WINAPI InternetCheckConnectionW( LPCWSTR lpszUrl, DWORD dwFlags, DWORD dwRe TRACE("Ping command is : %s\n",command);
status = system(command); - heap_free( command ); + free(command);
TRACE("Ping returned a code of %i\n",status);
@@ -3660,14 +3661,14 @@ BOOL WINAPI InternetCheckConnectionA(LPCSTR lpszUrl, DWORD dwFlags, DWORD dwRese BOOL rc;
if(lpszUrl) { - url = heap_strdupAtoW(lpszUrl); + url = strdupAtoW(lpszUrl); if(!url) return FALSE; }
rc = InternetCheckConnectionW(url, dwFlags, dwReserved);
- heap_free(url); + free(url); return rc; }
@@ -3706,12 +3707,12 @@ static HINTERNET INTERNET_InternetOpenUrlW(appinfo_t *hIC, LPCWSTR lpszUrl, urlComponents.dwUrlPathLength += urlComponents.dwExtraInfoLength; }
- host = heap_strndupW(urlComponents.lpszHostName, urlComponents.dwHostNameLength); - path = heap_strndupW(urlComponents.lpszUrlPath, urlComponents.dwUrlPathLength); + host = strndupW(urlComponents.lpszHostName, urlComponents.dwHostNameLength); + path = strndupW(urlComponents.lpszUrlPath, urlComponents.dwUrlPathLength); if(urlComponents.dwUserNameLength) - user = heap_strndupW(urlComponents.lpszUserName, urlComponents.dwUserNameLength); + user = strndupW(urlComponents.lpszUserName, urlComponents.dwUserNameLength); if(urlComponents.dwPasswordLength) - pass = heap_strndupW(urlComponents.lpszPassword, urlComponents.dwPasswordLength); + pass = strndupW(urlComponents.lpszPassword, urlComponents.dwPasswordLength);
switch(urlComponents.nScheme) { case INTERNET_SCHEME_FTP: @@ -3763,10 +3764,10 @@ static HINTERNET INTERNET_InternetOpenUrlW(appinfo_t *hIC, LPCWSTR lpszUrl,
TRACE(" %p <--\n", client1);
- heap_free(host); - heap_free(path); - heap_free(user); - heap_free(pass); + free(host); + free(path); + free(user); + free(pass); return client1; }
@@ -3795,8 +3796,8 @@ static void AsyncInternetOpenUrlProc(task_header_t *hdr)
INTERNET_InternetOpenUrlW((appinfo_t*)task->hdr.hdr, task->url, task->headers, task->headers_len, task->flags, task->context); - heap_free(task->url); - heap_free(task->headers); + free(task->url); + free(task->headers); }
HINTERNET WINAPI InternetOpenUrlW(HINTERNET hInternet, LPCWSTR lpszUrl, @@ -3828,8 +3829,8 @@ HINTERNET WINAPI InternetOpenUrlW(HINTERNET hInternet, LPCWSTR lpszUrl, open_url_task_t *task;
task = alloc_async_task(&hIC->hdr, AsyncInternetOpenUrlProc, sizeof(*task)); - task->url = heap_strdupW(lpszUrl); - task->headers = heap_strdupW(lpszHeaders); + task->url = wcsdup(lpszUrl); + task->headers = wcsdup(lpszHeaders); task->headers_len = dwHeadersLength; task->flags = dwFlags; task->context = dwContext; @@ -3866,30 +3867,30 @@ HINTERNET WINAPI InternetOpenUrlA(HINTERNET hInternet, LPCSTR lpszUrl, TRACE("\n");
if(lpszUrl) { - szUrl = heap_strdupAtoW(lpszUrl); + szUrl = strdupAtoW(lpszUrl); if(!szUrl) return NULL; }
if(lpszHeaders) { - headers = heap_strndupAtoW(lpszHeaders, dwHeadersLength, &dwHeadersLength); + headers = strndupAtoW(lpszHeaders, dwHeadersLength, &dwHeadersLength); if(!headers) { - heap_free(szUrl); + free(szUrl); return NULL; } }
rc = InternetOpenUrlW(hInternet, szUrl, headers, dwHeadersLength, dwFlags, dwContext);
- heap_free(szUrl); - heap_free(headers); + free(szUrl); + free(headers); return rc; }
static LPWITHREADERROR INTERNET_AllocThreadError(void) { - LPWITHREADERROR lpwite = heap_alloc(sizeof(*lpwite)); + WITHREADERROR *lpwite = malloc(sizeof(*lpwite));
if (lpwite) { @@ -3899,7 +3900,7 @@ static LPWITHREADERROR INTERNET_AllocThreadError(void)
if (!TlsSetValue(g_dwTlsErrIndex, lpwite)) { - heap_free(lpwite); + free(lpwite); return NULL; } return lpwite; @@ -3961,11 +3962,11 @@ static DWORD CALLBACK INTERNET_WorkerThreadFunc(LPVOID lpvParam)
task->proc(task); WININET_Release(task->hdr); - heap_free(task); + free(task);
if (g_dwTlsErrIndex != TLS_OUT_OF_INDEXES) { - heap_free(TlsGetValue(g_dwTlsErrIndex)); + free(TlsGetValue(g_dwTlsErrIndex)); TlsSetValue(g_dwTlsErrIndex, NULL); } return TRUE; @@ -3975,7 +3976,7 @@ void *alloc_async_task(object_header_t *hdr, async_task_proc_t proc, size_t size { task_header_t *task;
- task = heap_alloc(size); + task = malloc(size); if(!task) return NULL;
@@ -4001,7 +4002,7 @@ DWORD INTERNET_AsyncCall(task_header_t *task) bSuccess = QueueUserWorkItem(INTERNET_WorkerThreadFunc, task, WT_EXECUTELONGFUNCTION); if (!bSuccess) { - heap_free(task); + free(task); return ERROR_INTERNET_ASYNC_THREAD_FAILED; } return ERROR_SUCCESS; @@ -4069,15 +4070,15 @@ DWORD create_req_file(const WCHAR *file_name, req_file_t **ret) { req_file_t *req_file;
- req_file = heap_alloc_zero(sizeof(*req_file)); + req_file = calloc(1, sizeof(*req_file)); if(!req_file) return ERROR_NOT_ENOUGH_MEMORY;
req_file->ref = 1;
- req_file->file_name = heap_strdupW(file_name); + req_file->file_name = wcsdup(file_name); if(!req_file->file_name) { - heap_free(req_file); + free(req_file); return ERROR_NOT_ENOUGH_MEMORY; }
@@ -4101,9 +4102,9 @@ void req_file_release(req_file_t *req_file) DeleteFileW(req_file->file_name); if(req_file->file_handle && req_file->file_handle != INVALID_HANDLE_VALUE) CloseHandle(req_file->file_handle); - heap_free(req_file->file_name); - heap_free(req_file->url); - heap_free(req_file); + free(req_file->file_name); + free(req_file->url); + free(req_file); }
/*********************************************************************** @@ -4387,7 +4388,7 @@ static void convert_urlcomp_atow(LPURL_COMPONENTSA lpUrlComponents, LPURL_COMPON if (lpUrlComponents->lpszScheme) { len = URL_GET_COMP_LENGTHA(lpUrlComponents, Scheme) + 1; - urlCompW->lpszScheme = heap_alloc(len * sizeof(WCHAR)); + urlCompW->lpszScheme = malloc(len * sizeof(WCHAR)); MultiByteToWideChar(CP_ACP, 0, lpUrlComponents->lpszScheme, -1, urlCompW->lpszScheme, len); } @@ -4395,7 +4396,7 @@ static void convert_urlcomp_atow(LPURL_COMPONENTSA lpUrlComponents, LPURL_COMPON if (lpUrlComponents->lpszHostName) { len = URL_GET_COMP_LENGTHA(lpUrlComponents, HostName) + 1; - urlCompW->lpszHostName = heap_alloc(len * sizeof(WCHAR)); + urlCompW->lpszHostName = malloc(len * sizeof(WCHAR)); MultiByteToWideChar(CP_ACP, 0, lpUrlComponents->lpszHostName, -1, urlCompW->lpszHostName, len); } @@ -4403,7 +4404,7 @@ static void convert_urlcomp_atow(LPURL_COMPONENTSA lpUrlComponents, LPURL_COMPON if (lpUrlComponents->lpszUserName) { len = URL_GET_COMP_LENGTHA(lpUrlComponents, UserName) + 1; - urlCompW->lpszUserName = heap_alloc(len * sizeof(WCHAR)); + urlCompW->lpszUserName = malloc(len * sizeof(WCHAR)); MultiByteToWideChar(CP_ACP, 0, lpUrlComponents->lpszUserName, -1, urlCompW->lpszUserName, len); } @@ -4411,7 +4412,7 @@ static void convert_urlcomp_atow(LPURL_COMPONENTSA lpUrlComponents, LPURL_COMPON if (lpUrlComponents->lpszPassword) { len = URL_GET_COMP_LENGTHA(lpUrlComponents, Password) + 1; - urlCompW->lpszPassword = heap_alloc(len * sizeof(WCHAR)); + urlCompW->lpszPassword = malloc(len * sizeof(WCHAR)); MultiByteToWideChar(CP_ACP, 0, lpUrlComponents->lpszPassword, -1, urlCompW->lpszPassword, len); } @@ -4419,7 +4420,7 @@ static void convert_urlcomp_atow(LPURL_COMPONENTSA lpUrlComponents, LPURL_COMPON if (lpUrlComponents->lpszUrlPath) { len = URL_GET_COMP_LENGTHA(lpUrlComponents, UrlPath) + 1; - urlCompW->lpszUrlPath = heap_alloc(len * sizeof(WCHAR)); + urlCompW->lpszUrlPath = malloc(len * sizeof(WCHAR)); MultiByteToWideChar(CP_ACP, 0, lpUrlComponents->lpszUrlPath, -1, urlCompW->lpszUrlPath, len); } @@ -4427,7 +4428,7 @@ static void convert_urlcomp_atow(LPURL_COMPONENTSA lpUrlComponents, LPURL_COMPON if (lpUrlComponents->lpszExtraInfo) { len = URL_GET_COMP_LENGTHA(lpUrlComponents, ExtraInfo) + 1; - urlCompW->lpszExtraInfo = heap_alloc(len * sizeof(WCHAR)); + urlCompW->lpszExtraInfo = malloc(len * sizeof(WCHAR)); MultiByteToWideChar(CP_ACP, 0, lpUrlComponents->lpszExtraInfo, -1, urlCompW->lpszExtraInfo, len); } @@ -4456,7 +4457,7 @@ BOOL WINAPI InternetCreateUrlA(LPURL_COMPONENTSA lpUrlComponents, DWORD dwFlags, convert_urlcomp_atow(lpUrlComponents, &urlCompW);
if (lpszUrl) - urlW = heap_alloc(*lpdwUrlLength * sizeof(WCHAR)); + urlW = malloc(*lpdwUrlLength * sizeof(WCHAR));
ret = InternetCreateUrlW(&urlCompW, dwFlags, urlW, lpdwUrlLength);
@@ -4469,13 +4470,13 @@ BOOL WINAPI InternetCreateUrlA(LPURL_COMPONENTSA lpUrlComponents, DWORD dwFlags, if (ret) WideCharToMultiByte(CP_ACP, 0, urlW, -1, lpszUrl, *lpdwUrlLength + 1, NULL, NULL);
- heap_free(urlCompW.lpszScheme); - heap_free(urlCompW.lpszHostName); - heap_free(urlCompW.lpszUserName); - heap_free(urlCompW.lpszPassword); - heap_free(urlCompW.lpszUrlPath); - heap_free(urlCompW.lpszExtraInfo); - heap_free(urlW); + free(urlCompW.lpszScheme); + free(urlCompW.lpszHostName); + free(urlCompW.lpszUserName); + free(urlCompW.lpszPassword); + free(urlCompW.lpszUrlPath); + free(urlCompW.lpszExtraInfo); + free(urlW); return ret; }
@@ -4680,12 +4681,12 @@ BOOL WINAPI InternetGetSecurityInfoByURLA(LPSTR lpszURL, PCCERT_CHAIN_CONTEXT *p
TRACE("(%s %p %p)\n", debugstr_a(lpszURL), ppCertChain, pdwSecureFlags);
- url = heap_strdupAtoW(lpszURL); + url = strdupAtoW(lpszURL); if(!url) return FALSE;
res = InternetGetSecurityInfoByURLW(url, ppCertChain, pdwSecureFlags); - heap_free(url); + free(url); return res; }
diff --git a/dlls/wininet/internet.h b/dlls/wininet/internet.h index 141613dd120..6756488d5a5 100644 --- a/dlls/wininet/internet.h +++ b/dlls/wininet/internet.h @@ -23,7 +23,6 @@ #ifndef _WINE_INTERNET_H_ #define _WINE_INTERNET_H_
-#include "wine/heap.h" #include "wine/list.h"
#include <time.h> @@ -89,43 +88,7 @@ typedef struct BOOL is_valid_netconn(netconn_t *) DECLSPEC_HIDDEN; void close_netconn(netconn_t *) DECLSPEC_HIDDEN;
-static inline void * __WINE_ALLOC_SIZE(2) heap_realloc_zero(void *mem, size_t len) -{ - return HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, len); -} - -static inline LPWSTR heap_strdupW(LPCWSTR str) -{ - LPWSTR ret = NULL; - - if(str) { - DWORD size; - - size = (lstrlenW(str)+1)*sizeof(WCHAR); - ret = heap_alloc(size); - if(ret) - memcpy(ret, str, size); - } - - return ret; -} - -static inline char *heap_strdupA(const char *str) -{ - char *ret = NULL; - - if(str) { - DWORD size = strlen(str)+1; - - ret = heap_alloc(size); - if(ret) - memcpy(ret, str, size); - } - - return ret; -} - -static inline LPWSTR heap_strndupW(LPCWSTR str, UINT max_len) +static inline WCHAR *strndupW(const WCHAR *str, UINT max_len) { LPWSTR ret; UINT len; @@ -137,7 +100,7 @@ static inline LPWSTR heap_strndupW(LPCWSTR str, UINT max_len) if(str[len] == '\0') break;
- ret = heap_alloc(sizeof(WCHAR)*(len+1)); + ret = malloc(sizeof(WCHAR) * (len + 1)); if(ret) { memcpy(ret, str, sizeof(WCHAR)*len); ret[len] = '\0'; @@ -146,7 +109,7 @@ static inline LPWSTR heap_strndupW(LPCWSTR str, UINT max_len) return ret; }
-static inline WCHAR *heap_strndupAtoW(const char *str, int len_a, DWORD *len_w) +static inline WCHAR *strndupAtoW(const char *str, int len_a, DWORD *len_w) { WCHAR *ret = NULL;
@@ -157,7 +120,7 @@ static inline WCHAR *heap_strndupAtoW(const char *str, int len_a, DWORD *len_w) else if(len_a > 0) len_a = strnlen(str, len_a); len = MultiByteToWideChar(CP_ACP, 0, str, len_a, NULL, 0); - ret = heap_alloc((len+1)*sizeof(WCHAR)); + ret = malloc((len + 1) * sizeof(WCHAR)); if(ret) { MultiByteToWideChar(CP_ACP, 0, str, len_a, ret, len); ret[len] = 0; @@ -168,7 +131,7 @@ static inline WCHAR *heap_strndupAtoW(const char *str, int len_a, DWORD *len_w) return ret; }
-static inline WCHAR *heap_strdupAtoW(const char *str) +static inline WCHAR *strdupAtoW(const char *str) { LPWSTR ret = NULL;
@@ -176,7 +139,7 @@ static inline WCHAR *heap_strdupAtoW(const char *str) DWORD len;
len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0); - ret = heap_alloc(len*sizeof(WCHAR)); + ret = malloc(len * sizeof(WCHAR)); if(ret) MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len); } @@ -184,13 +147,13 @@ static inline WCHAR *heap_strdupAtoW(const char *str) return ret; }
-static inline char *heap_strdupWtoA(LPCWSTR str) +static inline char *strdupWtoA(const WCHAR *str) { char *ret = NULL;
if(str) { DWORD size = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL); - ret = heap_alloc(size); + ret = malloc(size); if(ret) WideCharToMultiByte(CP_ACP, 0, str, -1, ret, size, NULL, NULL); } diff --git a/dlls/wininet/netconnection.c b/dlls/wininet/netconnection.c index b3649b5a53b..40da064588b 100644 --- a/dlls/wininet/netconnection.c +++ b/dlls/wininet/netconnection.c @@ -344,7 +344,7 @@ DWORD create_netconn(server_t *server, DWORD security_flags, BOOL mask_errors, D netconn_t *netconn; int result;
- netconn = heap_alloc_zero(sizeof(*netconn)); + netconn = calloc(1, sizeof(*netconn)); if(!netconn) return ERROR_OUTOFMEMORY;
@@ -356,7 +356,7 @@ DWORD create_netconn(server_t *server, DWORD security_flags, BOOL mask_errors, D
result = create_netconn_socket(server, netconn, timeout); if (result != ERROR_SUCCESS) { - heap_free(netconn); + free(netconn); return result; }
@@ -382,13 +382,13 @@ void free_netconn(netconn_t *netconn) server_release(netconn->server);
if (netconn->secure) { - heap_free(netconn->peek_msg_mem); + free(netconn->peek_msg_mem); netconn->peek_msg_mem = NULL; netconn->peek_msg = NULL; netconn->peek_len = 0; - heap_free(netconn->ssl_buf); + free(netconn->ssl_buf); netconn->ssl_buf = NULL; - heap_free(netconn->extra_buf); + free(netconn->extra_buf); netconn->extra_buf = NULL; netconn->extra_len = 0; } @@ -396,7 +396,7 @@ void free_netconn(netconn_t *netconn) DeleteSecurityContext(&netconn->ssl_ctx);
close_netconn(netconn); - heap_free(netconn); + free(netconn); }
void NETCON_unload(void) @@ -459,7 +459,7 @@ static DWORD netcon_secure_connect_setup(netconn_t *connection, BOOL compat_mode cred = &compat_cred_handle; }
- read_buf = heap_alloc(read_buf_size); + read_buf = malloc(read_buf_size); if(!read_buf) return ERROR_OUTOFMEMORY;
@@ -503,7 +503,7 @@ static DWORD netcon_secure_connect_setup(netconn_t *connection, BOOL compat_mode if(in_bufs[0].cbBuffer + 1024 > read_buf_size) { BYTE *new_read_buf;
- new_read_buf = heap_realloc(read_buf, read_buf_size + 1024); + new_read_buf = realloc(read_buf, read_buf_size + 1024); if(!new_read_buf) { status = E_OUTOFMEMORY; break; @@ -555,7 +555,7 @@ static DWORD netcon_secure_connect_setup(netconn_t *connection, BOOL compat_mode break; }
- connection->ssl_buf = heap_alloc(connection->ssl_sizes.cbHeader + connection->ssl_sizes.cbMaximumMessage + connection->ssl_buf = malloc(connection->ssl_sizes.cbHeader + connection->ssl_sizes.cbMaximumMessage + connection->ssl_sizes.cbTrailer); if(!connection->ssl_buf) { res = GetLastError(); @@ -564,11 +564,11 @@ static DWORD netcon_secure_connect_setup(netconn_t *connection, BOOL compat_mode } }
- heap_free(read_buf); + free(read_buf);
if(status != SEC_E_OK || res != ERROR_SUCCESS) { WARN("Failed to establish SSL connection: %08lx (%lu)\n", status, res); - heap_free(connection->ssl_buf); + free(connection->ssl_buf); connection->ssl_buf = NULL; return res ? res : ERROR_INTERNET_SECURITY_CHANNEL_ERROR; } @@ -706,7 +706,7 @@ static BOOL read_ssl_chunk(netconn_t *conn, void *buf, SIZE_T buf_size, BOOL blo memcpy(conn->ssl_buf, conn->extra_buf, conn->extra_len); buf_len = conn->extra_len; conn->extra_len = 0; - heap_free(conn->extra_buf); + free(conn->extra_buf); conn->extra_buf = NULL; }
@@ -758,7 +758,7 @@ static BOOL read_ssl_chunk(netconn_t *conn, void *buf, SIZE_T buf_size, BOOL blo TRACE("would block\n");
/* FIXME: Optimize extra_buf usage. */ - conn->extra_buf = heap_alloc(buf_len); + conn->extra_buf = malloc(buf_len); if(!conn->extra_buf) return ERROR_NOT_ENOUGH_MEMORY;
@@ -784,7 +784,7 @@ static BOOL read_ssl_chunk(netconn_t *conn, void *buf, SIZE_T buf_size, BOOL blo memcpy(buf, bufs[i].pvBuffer, size); if(size < bufs[i].cbBuffer) { assert(!conn->peek_len); - conn->peek_msg_mem = conn->peek_msg = heap_alloc(bufs[i].cbBuffer - size); + conn->peek_msg_mem = conn->peek_msg = malloc(bufs[i].cbBuffer - size); if(!conn->peek_msg) return ERROR_NOT_ENOUGH_MEMORY; conn->peek_len = bufs[i].cbBuffer-size; @@ -797,7 +797,7 @@ static BOOL read_ssl_chunk(netconn_t *conn, void *buf, SIZE_T buf_size, BOOL blo
for(i = 0; i < ARRAY_SIZE(bufs); i++) { if(bufs[i].BufferType == SECBUFFER_EXTRA) { - conn->extra_buf = heap_alloc(bufs[i].cbBuffer); + conn->extra_buf = malloc(bufs[i].cbBuffer); if(!conn->extra_buf) return ERROR_NOT_ENOUGH_MEMORY;
@@ -839,7 +839,7 @@ DWORD NETCON_recv(netconn_t *connection, void *buf, size_t len, BOOL blocking, i connection->peek_msg += size;
if(!connection->peek_len) { - heap_free(connection->peek_msg_mem); + free(connection->peek_msg_mem); connection->peek_msg_mem = connection->peek_msg = NULL; }
diff --git a/dlls/wininet/urlcache.c b/dlls/wininet/urlcache.c index 8b175ea2b3c..8118bae50dc 100644 --- a/dlls/wininet/urlcache.c +++ b/dlls/wininet/urlcache.c @@ -199,13 +199,13 @@ typedef struct /* List of all containers available */ static struct list UrlContainers = LIST_INIT(UrlContainers);
-static inline char *heap_strdupWtoUTF8(LPCWSTR str) +static inline char *strdupWtoUTF8(const WCHAR *str) { char *ret = NULL;
if(str) { DWORD size = WideCharToMultiByte(CP_UTF8, 0, str, -1, NULL, 0, NULL, NULL); - ret = heap_alloc(size); + ret = malloc(size); if(ret) WideCharToMultiByte(CP_UTF8, 0, str, -1, ret, size, NULL, NULL); } @@ -677,7 +677,7 @@ static void cache_container_close_index(cache_container *pContainer) static BOOL cache_containers_add(const char *cache_prefix, LPCWSTR path, DWORD default_entry_type, LPWSTR mutex_name) { - cache_container *pContainer = heap_alloc(sizeof(cache_container)); + cache_container *pContainer = malloc(sizeof(cache_container)); int cache_prefix_len = strlen(cache_prefix);
if (!pContainer) @@ -689,18 +689,18 @@ static BOOL cache_containers_add(const char *cache_prefix, LPCWSTR path, pContainer->file_size = 0; pContainer->default_entry_type = default_entry_type;
- pContainer->path = heap_strdupW(path); + pContainer->path = wcsdup(path); if (!pContainer->path) { - heap_free(pContainer); + free(pContainer); return FALSE; }
- pContainer->cache_prefix = heap_alloc(cache_prefix_len+1); + pContainer->cache_prefix = malloc(cache_prefix_len+1); if (!pContainer->cache_prefix) { - heap_free(pContainer->path); - heap_free(pContainer); + free(pContainer->path); + free(pContainer); return FALSE; }
@@ -712,8 +712,8 @@ static BOOL cache_containers_add(const char *cache_prefix, LPCWSTR path, if ((pContainer->mutex = CreateMutexW(NULL, FALSE, mutex_name)) == NULL) { ERR("couldn't create mutex (error is %ld)\n", GetLastError()); - heap_free(pContainer->path); - heap_free(pContainer); + free(pContainer->path); + free(pContainer); return FALSE; }
@@ -728,9 +728,9 @@ static void cache_container_delete_container(cache_container *pContainer)
cache_container_close_index(pContainer); CloseHandle(pContainer->mutex); - heap_free(pContainer->path); - heap_free(pContainer->cache_prefix); - heap_free(pContainer); + free(pContainer->path); + free(pContainer->cache_prefix); + free(pContainer); }
static void cache_containers_init(void) @@ -1219,17 +1219,17 @@ static int urlcache_decode_url(const char *url, WCHAR *decoded_url, int decoded_ if(decoded_url) decoded_len -= len;
- host_name = heap_alloc(uc.dwHostNameLength*sizeof(WCHAR)); + host_name = malloc(uc.dwHostNameLength * sizeof(WCHAR)); if(!host_name) return 0; if(!MultiByteToWideChar(CP_UTF8, 0, uc.lpszHostName, uc.dwHostNameLength, host_name, uc.dwHostNameLength)) { - heap_free(host_name); + free(host_name); return 0; } part_len = IdnToUnicode(0, host_name, uc.dwHostNameLength, decoded_url ? decoded_url+len : NULL, decoded_len); - heap_free(host_name); + free(host_name); if(!part_len) { SetLastError(ERROR_INTERNET_INVALID_URL); return 0; @@ -1888,19 +1888,19 @@ static int urlcache_encode_url(const WCHAR *url, char *encoded_url, int encoded_ return 0; }
- punycode = heap_alloc(part_len*sizeof(WCHAR)); + punycode = malloc(part_len * sizeof(WCHAR)); if(!punycode) return 0;
part_len = IdnToAscii(0, uc.lpszHostName, uc.dwHostNameLength, punycode, part_len); if(!part_len) { - heap_free(punycode); + free(punycode); return 0; }
part_len = WideCharToMultiByte(CP_UTF8, 0, punycode, part_len, encoded_url ? encoded_url+len : NULL, encoded_len, NULL, NULL); - heap_free(punycode); + free(punycode); if(!part_len) return 0; if(encoded_url) @@ -1926,13 +1926,13 @@ static BOOL urlcache_encode_url_alloc(const WCHAR *url, char **encoded_url) if(!encoded_len) return FALSE;
- ret = heap_alloc(encoded_len*sizeof(WCHAR)); + ret = malloc(encoded_len * sizeof(WCHAR)); if(!ret) return FALSE;
encoded_len = urlcache_encode_url(url, ret, encoded_len); if(!encoded_len) { - heap_free(ret); + free(ret); return FALSE; }
@@ -1966,7 +1966,7 @@ BOOL WINAPI GetUrlCacheEntryInfoExW(LPCWSTR lpszUrl,
ret = urlcache_get_entry_info(url, lpCacheEntryInfo, lpdwCacheEntryInfoBufSize, dwFlags, TRUE); - heap_free(url); + free(url); return ret; }
@@ -2052,7 +2052,7 @@ BOOL WINAPI SetUrlCacheEntryInfoW(LPCWSTR lpszUrl, return FALSE;
ret = SetUrlCacheEntryInfoA(url, (INTERNET_CACHE_ENTRY_INFOA*)lpCacheEntryInfo, dwFieldControl); - heap_free(url); + free(url); return ret; }
@@ -2159,7 +2159,7 @@ BOOL WINAPI RetrieveUrlCacheEntryFileW(LPCWSTR lpszUrlName,
ret = urlcache_entry_get_file(url, lpCacheEntryInfo, lpdwCacheEntryInfoBufferSize, TRUE); - heap_free(url); + free(url); return ret; }
@@ -2496,10 +2496,10 @@ BOOL WINAPI FreeUrlCacheSpaceW(LPCWSTR cache_path, DWORD size, DWORD filter) BOOL WINAPI FreeUrlCacheSpaceA(LPCSTR lpszCachePath, DWORD dwSize, DWORD dwFilter) { BOOL ret = FALSE; - LPWSTR path = heap_strdupAtoW(lpszCachePath); + WCHAR *path = strdupAtoW(lpszCachePath); if (lpszCachePath == NULL || path != NULL) ret = FreeUrlCacheSpaceW(path, dwSize, dwFilter); - heap_free(path); + free(path); return ret; }
@@ -2592,7 +2592,7 @@ BOOL WINAPI UnlockUrlCacheEntryFileW(LPCWSTR lpszUrlName, DWORD dwReserved) return FALSE;
ret = UnlockUrlCacheEntryFileA(url, dwReserved); - heap_free(url); + free(url); return ret; }
@@ -2787,19 +2787,19 @@ BOOL WINAPI CreateUrlCacheEntryW(LPCWSTR lpszUrlName, DWORD dwExpectedFileSize, FIXME("dwReserved 0x%08lx\n", dwReserved);
if(lpszFileExtension) { - ext = heap_strdupWtoUTF8(lpszFileExtension); + ext = strdupWtoUTF8(lpszFileExtension); if(!ext) return FALSE; }
if(!urlcache_encode_url_alloc(lpszUrlName, &url)) { - heap_free(ext); + free(ext); return FALSE; }
ret = urlcache_entry_create(url, ext, lpszFileName); - heap_free(ext); - heap_free(url); + free(ext); + free(url); return ret; }
@@ -3033,14 +3033,14 @@ BOOL WINAPI CommitUrlCacheEntryA(LPCSTR lpszUrlName, LPCSTR lpszLocalFileName, BOOL ret;
if(lpszLocalFileName) { - file_name = heap_strdupAtoW(lpszLocalFileName); + file_name = strdupAtoW(lpszLocalFileName); if(!file_name) return FALSE; }
ret = urlcache_entry_commit(lpszUrlName, file_name, ExpireTime, LastModifiedTime, CacheEntryType, lpHeaderInfo, dwHeaderSize, lpszFileExtension, lpszOriginalUrl); - heap_free(file_name); + free(file_name); return ret; }
@@ -3058,36 +3058,36 @@ BOOL WINAPI CommitUrlCacheEntryW(LPCWSTR lpszUrlName, LPCWSTR lpszLocalFileName, return FALSE;
if(lpHeaderInfo) { - header_info = heap_strdupWtoUTF8(lpHeaderInfo); + header_info = strdupWtoUTF8(lpHeaderInfo); if(!header_info) { - heap_free(url); + free(url); return FALSE; } dwHeaderSize = strlen(header_info); }
if(lpszFileExtension) { - file_ext = heap_strdupWtoA(lpszFileExtension); + file_ext = strdupWtoA(lpszFileExtension); if(!file_ext) { - heap_free(url); - heap_free(header_info); + free(url); + free(header_info); return FALSE; } }
if(lpszOriginalUrl && !urlcache_encode_url_alloc(lpszOriginalUrl, &original_url)) { - heap_free(url); - heap_free(header_info); - heap_free(file_ext); + free(url); + free(header_info); + free(file_ext); return FALSE; }
ret = urlcache_entry_commit(url, lpszLocalFileName, ExpireTime, LastModifiedTime, CacheEntryType, (BYTE*)header_info, dwHeaderSize, file_ext, original_url); - heap_free(url); - heap_free(header_info); - heap_free(file_ext); - heap_free(original_url); + free(url); + free(header_info); + free(file_ext); + free(original_url); return ret; }
@@ -3156,7 +3156,7 @@ HANDLE WINAPI RetrieveUrlCacheEntryStreamA(LPCSTR lpszUrlName, }
/* allocate handle storage space */ - stream = heap_alloc(sizeof(stream_handle) + strlen(lpszUrlName) * sizeof(CHAR)); + stream = malloc(sizeof(stream_handle) + strlen(lpszUrlName) * sizeof(CHAR)); if(!stream) { CloseHandle(file); UnlockUrlCacheEntryFileA(lpszUrlName, 0); @@ -3205,7 +3205,7 @@ HANDLE WINAPI RetrieveUrlCacheEntryStreamW(LPCWSTR lpszUrlName, }
/* allocate handle storage space */ - stream = heap_alloc(sizeof(stream_handle) + len*sizeof(WCHAR)); + stream = malloc(sizeof(stream_handle) + len * sizeof(WCHAR)); if(!stream) { CloseHandle(file); UnlockUrlCacheEntryFileW(lpszUrlName, 0); @@ -3217,7 +3217,7 @@ HANDLE WINAPI RetrieveUrlCacheEntryStreamW(LPCWSTR lpszUrlName, if(!urlcache_encode_url(lpszUrlName, stream->url, len)) { CloseHandle(file); UnlockUrlCacheEntryFileW(lpszUrlName, 0); - heap_free(stream); + free(stream); return NULL; } return stream; @@ -3251,7 +3251,7 @@ BOOL WINAPI UnlockUrlCacheEntryStream( return FALSE;
CloseHandle(pStream->file); - heap_free(pStream); + free(pStream); return TRUE; }
@@ -3315,7 +3315,7 @@ BOOL WINAPI DeleteUrlCacheEntryW(LPCWSTR lpszUrlName) return FALSE;
ret = DeleteUrlCacheEntryA(url); - heap_free(url); + free(url); return ret; }
@@ -3438,17 +3438,17 @@ INTERNETAPI HANDLE WINAPI FindFirstUrlCacheEntryA(LPCSTR lpszUrlSearchPattern,
TRACE("(%s, %p, %p)\n", debugstr_a(lpszUrlSearchPattern), lpFirstCacheEntryInfo, lpdwFirstCacheEntryInfoBufferSize);
- pEntryHandle = heap_alloc(sizeof(*pEntryHandle)); + pEntryHandle = malloc(sizeof(*pEntryHandle)); if (!pEntryHandle) return NULL;
pEntryHandle->magic = URLCACHE_FIND_ENTRY_HANDLE_MAGIC; if (lpszUrlSearchPattern) { - pEntryHandle->url_search_pattern = heap_strdupA(lpszUrlSearchPattern); + pEntryHandle->url_search_pattern = strdup(lpszUrlSearchPattern); if (!pEntryHandle->url_search_pattern) { - heap_free(pEntryHandle); + free(pEntryHandle); return NULL; } } @@ -3460,7 +3460,7 @@ INTERNETAPI HANDLE WINAPI FindFirstUrlCacheEntryA(LPCSTR lpszUrlSearchPattern,
if (!FindNextUrlCacheEntryA(pEntryHandle, lpFirstCacheEntryInfo, lpdwFirstCacheEntryInfoBufferSize)) { - heap_free(pEntryHandle); + free(pEntryHandle); return NULL; } return pEntryHandle; @@ -3477,17 +3477,17 @@ INTERNETAPI HANDLE WINAPI FindFirstUrlCacheEntryW(LPCWSTR lpszUrlSearchPattern,
TRACE("(%s, %p, %p)\n", debugstr_w(lpszUrlSearchPattern), lpFirstCacheEntryInfo, lpdwFirstCacheEntryInfoBufferSize);
- pEntryHandle = heap_alloc(sizeof(*pEntryHandle)); + pEntryHandle = malloc(sizeof(*pEntryHandle)); if (!pEntryHandle) return NULL;
pEntryHandle->magic = URLCACHE_FIND_ENTRY_HANDLE_MAGIC; if (lpszUrlSearchPattern) { - pEntryHandle->url_search_pattern = heap_strdupWtoA(lpszUrlSearchPattern); + pEntryHandle->url_search_pattern = strdupWtoA(lpszUrlSearchPattern); if (!pEntryHandle->url_search_pattern) { - heap_free(pEntryHandle); + free(pEntryHandle); return NULL; } } @@ -3499,7 +3499,7 @@ INTERNETAPI HANDLE WINAPI FindFirstUrlCacheEntryW(LPCWSTR lpszUrlSearchPattern,
if (!FindNextUrlCacheEntryW(pEntryHandle, lpFirstCacheEntryInfo, lpdwFirstCacheEntryInfoBufferSize)) { - heap_free(pEntryHandle); + free(pEntryHandle); return NULL; } return pEntryHandle; @@ -3634,8 +3634,8 @@ BOOL WINAPI FindCloseUrlCache(HANDLE hEnumHandle) }
pEntryHandle->magic = 0; - heap_free(pEntryHandle->url_search_pattern); - heap_free(pEntryHandle); + free(pEntryHandle->url_search_pattern); + free(pEntryHandle); return TRUE; }
@@ -4017,7 +4017,7 @@ BOOL WINAPI IsUrlCacheEntryExpiredW(LPCWSTR url, DWORD dwFlags, FILETIME* pftLas return FALSE;
ret = IsUrlCacheEntryExpiredA(encoded_url, dwFlags, pftLastModified); - heap_free(encoded_url); + free(encoded_url); return ret; }
diff --git a/dlls/wininet/utility.c b/dlls/wininet/utility.c index 96d9d520ad9..a9a0b9f8d94 100644 --- a/dlls/wininet/utility.c +++ b/dlls/wininet/utility.c @@ -248,17 +248,17 @@ void INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR context, DWORD status case INTERNET_STATUS_NAME_RESOLVED: case INTERNET_STATUS_CONNECTING_TO_SERVER: case INTERNET_STATUS_CONNECTED_TO_SERVER: - new_info = heap_alloc(info_len); + new_info = malloc(info_len); if(new_info) memcpy(new_info, info, info_len); break; case INTERNET_STATUS_RESOLVING_NAME: case INTERNET_STATUS_REDIRECT: if(hdr->dwInternalFlags & INET_CALLBACKW) { - new_info = heap_strdupW(info); + new_info = wcsdup(info); break; }else { - new_info = heap_strdupWtoA(info); + new_info = strdupWtoA(info); info_len = strlen(new_info)+1; break; } @@ -273,5 +273,5 @@ void INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR context, DWORD status TRACE(" end callback().\n");
if(new_info != info) - heap_free(new_info); + free(new_info); }