wininet: Use standard C functions for memory allocation.

This commit is contained in:
Alex Henrie 2022-11-24 21:13:01 -07:00 committed by Alexandre Julliard
parent d673b697eb
commit db691cd9d0
9 changed files with 648 additions and 678 deletions

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

File diff suppressed because it is too large Load diff

View file

@ -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;
}

View file

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

View file

@ -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;
}

View file

@ -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;
}

View file

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