Commit db691cd9 authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

wininet: Use standard C functions for memory allocation.

parent d673b697
......@@ -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;
}
......
......@@ -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);
}
......
......@@ -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;
}
......
......@@ -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);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment