Commit 105d1677 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

webservices: Use CRT allocation functions.

parent b072f01e
......@@ -25,7 +25,6 @@
#include "webservices.h"
#include "wine/debug.h"
#include "wine/heap.h"
#include "wine/list.h"
#include "webservices_private.h"
#include "sock.h"
......@@ -132,7 +131,7 @@ static void CALLBACK queue_runner( TP_CALLBACK_INSTANCE *instance, void *ctx )
while ((task = dequeue_task( queue )))
{
task->proc( task );
heap_free( task );
free( task );
}
break;
}
......@@ -249,7 +248,7 @@ static struct channel *alloc_channel(void)
struct channel *ret;
ULONG size = sizeof(*ret) + prop_size( channel_props, count );
if (!(ret = heap_alloc_zero( size ))) return NULL;
if (!(ret = calloc( 1, size ))) return NULL;
ret->magic = CHANNEL_MAGIC;
InitializeCriticalSection( &ret->cs );
......@@ -266,7 +265,7 @@ static struct channel *alloc_channel(void)
static void clear_addr( WS_ENDPOINT_ADDRESS *addr )
{
heap_free( addr->url.chars );
free( addr->url.chars );
addr->url.chars = NULL;
addr->url.length = 0;
}
......@@ -282,7 +281,7 @@ static void clear_queue( struct queue *queue )
{
struct task *task = LIST_ENTRY( ptr, struct task, entry );
list_remove( &task->entry );
heap_free( task );
free( task );
}
CloseHandle( queue->wait );
......@@ -342,7 +341,7 @@ static void reset_channel( struct channel *channel )
channel->u.http.connect = NULL;
WinHttpCloseHandle( channel->u.http.session );
channel->u.http.session = NULL;
heap_free( channel->u.http.path );
free( channel->u.http.path );
channel->u.http.path = NULL;
channel->u.http.flags = 0;
break;
......@@ -364,8 +363,8 @@ static void reset_channel( struct channel *channel )
static void free_header_mappings( WS_HTTP_HEADER_MAPPING **mappings, ULONG count )
{
ULONG i;
for (i = 0; i < count; i++) heap_free( mappings[i] );
heap_free( mappings );
for (i = 0; i < count; i++) free( mappings[i] );
free( mappings );
}
static void free_message_mapping( const WS_HTTP_MESSAGE_MAPPING *mapping )
......@@ -389,8 +388,8 @@ static void free_channel( struct channel *channel )
WsFreeWriter( channel->writer );
WsFreeReader( channel->reader );
heap_free( channel->read_buf );
heap_free( channel->send_buf );
free( channel->read_buf );
free( channel->send_buf );
free_props( channel );
channel->send_q.cs.DebugInfo->Spare[0] = 0;
......@@ -399,14 +398,14 @@ static void free_channel( struct channel *channel )
DeleteCriticalSection( &channel->send_q.cs );
DeleteCriticalSection( &channel->recv_q.cs );
DeleteCriticalSection( &channel->cs );
heap_free( channel );
free( channel );
}
static WS_HTTP_HEADER_MAPPING *dup_header_mapping( const WS_HTTP_HEADER_MAPPING *src )
{
WS_HTTP_HEADER_MAPPING *dst;
if (!(dst = heap_alloc( sizeof(*dst) + src->headerName.length ))) return NULL;
if (!(dst = malloc( sizeof(*dst) + src->headerName.length ))) return NULL;
dst->headerName.bytes = (BYTE *)(dst + 1);
memcpy( dst->headerName.bytes, src->headerName.bytes, src->headerName.length );
......@@ -420,7 +419,7 @@ static HRESULT dup_message_mapping( const WS_HTTP_MESSAGE_MAPPING *src, WS_HTTP_
ULONG i, size;
size = src->requestHeaderMappingCount * sizeof(*dst->responseHeaderMappings);
if (!(dst->requestHeaderMappings = heap_alloc( size ))) return E_OUTOFMEMORY;
if (!(dst->requestHeaderMappings = malloc( size ))) return E_OUTOFMEMORY;
for (i = 0; i < src->requestHeaderMappingCount; i++)
{
......@@ -432,9 +431,9 @@ static HRESULT dup_message_mapping( const WS_HTTP_MESSAGE_MAPPING *src, WS_HTTP_
}
size = src->responseHeaderMappingCount * sizeof(*dst->responseHeaderMappings);
if (!(dst->responseHeaderMappings = heap_alloc( size )))
if (!(dst->responseHeaderMappings = malloc( size )))
{
heap_free( dst->responseHeaderMappings );
free( dst->responseHeaderMappings );
return E_OUTOFMEMORY;
}
......@@ -848,7 +847,7 @@ static HRESULT queue_shutdown_session( struct channel *channel, const WS_ASYNC_C
{
struct shutdown_session *s;
if (!(s = heap_alloc( sizeof(*s) ))) return E_OUTOFMEMORY;
if (!(s = malloc( sizeof(*s) ))) return E_OUTOFMEMORY;
s->task.proc = shutdown_session_proc;
s->channel = channel;
s->ctx = *ctx;
......@@ -921,7 +920,7 @@ static HRESULT queue_close_channel( struct channel *channel, const WS_ASYNC_CONT
{
struct close_channel *c;
if (!(c = heap_alloc( sizeof(*c) ))) return E_OUTOFMEMORY;
if (!(c = malloc( sizeof(*c) ))) return E_OUTOFMEMORY;
c->task.proc = close_channel_proc;
c->channel = channel;
c->ctx = *ctx;
......@@ -973,11 +972,11 @@ static HRESULT parse_http_url( const WCHAR *url, ULONG len, URL_COMPONENTS *uc )
memset( uc, 0, sizeof(*uc) );
uc->dwStructSize = sizeof(*uc);
uc->dwHostNameLength = 128;
uc->lpszHostName = heap_alloc( uc->dwHostNameLength * sizeof(WCHAR) );
uc->lpszHostName = malloc( uc->dwHostNameLength * sizeof(WCHAR) );
uc->dwUrlPathLength = 128;
uc->lpszUrlPath = heap_alloc( uc->dwUrlPathLength * sizeof(WCHAR) );
uc->lpszUrlPath = malloc( uc->dwUrlPathLength * sizeof(WCHAR) );
uc->dwExtraInfoLength = 128;
uc->lpszExtraInfo = heap_alloc( uc->dwExtraInfoLength * sizeof(WCHAR) );
uc->lpszExtraInfo = malloc( uc->dwExtraInfoLength * sizeof(WCHAR) );
if (!uc->lpszHostName || !uc->lpszUrlPath || !uc->lpszExtraInfo) goto error;
if (!WinHttpCrackUrl( url, len, ICU_DECODE, uc ))
......@@ -987,11 +986,11 @@ static HRESULT parse_http_url( const WCHAR *url, ULONG len, URL_COMPONENTS *uc )
hr = HRESULT_FROM_WIN32( err );
goto error;
}
if (!(tmp = heap_realloc( uc->lpszHostName, uc->dwHostNameLength * sizeof(WCHAR) ))) goto error;
if (!(tmp = realloc( uc->lpszHostName, uc->dwHostNameLength * sizeof(WCHAR) ))) goto error;
uc->lpszHostName = tmp;
if (!(tmp = heap_realloc( uc->lpszUrlPath, uc->dwUrlPathLength * sizeof(WCHAR) ))) goto error;
if (!(tmp = realloc( uc->lpszUrlPath, uc->dwUrlPathLength * sizeof(WCHAR) ))) goto error;
uc->lpszUrlPath = tmp;
if (!(tmp = heap_realloc( uc->lpszExtraInfo, uc->dwExtraInfoLength * sizeof(WCHAR) ))) goto error;
if (!(tmp = realloc( uc->lpszExtraInfo, uc->dwExtraInfoLength * sizeof(WCHAR) ))) goto error;
uc->lpszExtraInfo = tmp;
WinHttpCrackUrl( url, len, ICU_DECODE, uc );
}
......@@ -999,9 +998,9 @@ static HRESULT parse_http_url( const WCHAR *url, ULONG len, URL_COMPONENTS *uc )
return S_OK;
error:
heap_free( uc->lpszHostName );
heap_free( uc->lpszUrlPath );
heap_free( uc->lpszExtraInfo );
free( uc->lpszHostName );
free( uc->lpszUrlPath );
free( uc->lpszExtraInfo );
return hr;
}
......@@ -1014,7 +1013,7 @@ static HRESULT open_channel_http( struct channel *channel )
if (channel->u.http.connect) return S_OK;
if ((hr = parse_http_url( channel->addr.url.chars, channel->addr.url.length, &uc )) != S_OK) return hr;
if (!(channel->u.http.path = heap_alloc( (uc.dwUrlPathLength + uc.dwExtraInfoLength + 1) * sizeof(WCHAR) )))
if (!(channel->u.http.path = malloc( (uc.dwUrlPathLength + uc.dwExtraInfoLength + 1) * sizeof(WCHAR) )))
{
hr = E_OUTOFMEMORY;
goto done;
......@@ -1058,9 +1057,9 @@ done:
WinHttpCloseHandle( con );
WinHttpCloseHandle( ses );
}
heap_free( uc.lpszHostName );
heap_free( uc.lpszUrlPath );
heap_free( uc.lpszExtraInfo );
free( uc.lpszHostName );
free( uc.lpszUrlPath );
free( uc.lpszExtraInfo );
return hr;
}
......@@ -1080,14 +1079,14 @@ static HRESULT open_channel_tcp( struct channel *channel )
if ((hr = parse_url( &channel->addr.url, &scheme, &host, &port )) != S_OK) return hr;
if (scheme != WS_URL_NETTCP_SCHEME_TYPE)
{
heap_free( host );
free( host );
return WS_E_INVALID_ENDPOINT_URL;
}
winsock_init();
hr = resolve_hostname( host, port, addr, &addr_len, 0 );
heap_free( host );
free( host );
if (hr != S_OK) return hr;
if ((channel->u.tcp.socket = socket( addr->sa_family, SOCK_STREAM, 0 )) == -1)
......@@ -1120,14 +1119,14 @@ static HRESULT open_channel_udp( struct channel *channel )
if ((hr = parse_url( &channel->addr.url, &scheme, &host, &port )) != S_OK) return hr;
if (scheme != WS_URL_SOAPUDP_SCHEME_TYPE)
{
heap_free( host );
free( host );
return WS_E_INVALID_ENDPOINT_URL;
}
winsock_init();
hr = resolve_hostname( host, port, addr, &addr_len, 0 );
heap_free( host );
free( host );
if (hr != S_OK) return hr;
if ((channel->u.udp.socket = socket( addr->sa_family, SOCK_DGRAM, 0 )) == -1)
......@@ -1155,7 +1154,7 @@ static HRESULT open_channel( struct channel *channel, const WS_ENDPOINT_ADDRESS
TRACE( "endpoint %s\n", debugstr_wn(endpoint->url.chars, endpoint->url.length) );
if (!(channel->addr.url.chars = heap_alloc( endpoint->url.length * sizeof(WCHAR) ))) return E_OUTOFMEMORY;
if (!(channel->addr.url.chars = malloc( endpoint->url.length * sizeof(WCHAR) ))) return E_OUTOFMEMORY;
memcpy( channel->addr.url.chars, endpoint->url.chars, endpoint->url.length * sizeof(WCHAR) );
channel->addr.url.length = endpoint->url.length;
......@@ -1207,7 +1206,7 @@ static HRESULT queue_open_channel( struct channel *channel, const WS_ENDPOINT_AD
{
struct open_channel *o;
if (!(o = heap_alloc( sizeof(*o) ))) return E_OUTOFMEMORY;
if (!(o = malloc( sizeof(*o) ))) return E_OUTOFMEMORY;
o->task.proc = open_channel_proc;
o->channel = channel;
o->endpoint = endpoint;
......@@ -1279,7 +1278,7 @@ static HRESULT write_bytes( struct channel *channel, BYTE *bytes, ULONG len )
if (!channel->send_buf)
{
channel->send_buflen = get_max_buffer_size( channel );
if (!(channel->send_buf = heap_alloc( channel->send_buflen ))) return E_OUTOFMEMORY;
if (!(channel->send_buf = malloc( channel->send_buflen ))) return E_OUTOFMEMORY;
}
if (channel->send_size + len >= channel->send_buflen) return WS_E_QUOTA_EXCEEDED;
......@@ -1344,7 +1343,7 @@ static HRESULT write_string_table( struct channel *channel, const struct diction
static HRESULT string_to_utf8( const WS_STRING *str, unsigned char **ret, int *len )
{
*len = WideCharToMultiByte( CP_UTF8, 0, str->chars, str->length, NULL, 0, NULL, NULL );
if (!(*ret = heap_alloc( *len ))) return E_OUTOFMEMORY;
if (!(*ret = malloc( *len ))) return E_OUTOFMEMORY;
WideCharToMultiByte( CP_UTF8, 0, str->chars, str->length, (char *)*ret, *len, NULL, NULL );
return S_OK;
}
......@@ -1441,7 +1440,7 @@ static HRESULT write_preamble( struct channel *channel )
hr = write_byte( channel, FRAME_RECORD_TYPE_PREAMBLE_END );
done:
heap_free( url );
free( url );
return hr;
}
......@@ -1597,14 +1596,14 @@ static HRESULT CALLBACK dict_cb( void *state, const WS_XML_STRING *str, BOOL *fo
return S_OK;
}
if (!(bytes = heap_alloc( str->length ))) return E_OUTOFMEMORY;
if (!(bytes = malloc( str->length ))) return E_OUTOFMEMORY;
memcpy( bytes, str->bytes, str->length );
if ((hr = insert_string( dict, bytes, str->length, index, id )) == S_OK)
{
*found = TRUE;
return S_OK;
}
heap_free( bytes );
free( bytes );
*found = FALSE;
return hr;
......@@ -1723,7 +1722,7 @@ static HRESULT queue_send_message( struct channel *channel, WS_MESSAGE *msg, con
{
struct send_message *s;
if (!(s = heap_alloc( sizeof(*s) ))) return E_OUTOFMEMORY;
if (!(s = malloc( sizeof(*s) ))) return E_OUTOFMEMORY;
s->task.proc = send_message_proc;
s->channel = channel;
s->msg = msg;
......@@ -1833,7 +1832,7 @@ static HRESULT resize_read_buffer( struct channel *channel, ULONG size )
{
if (!channel->read_buf)
{
if (!(channel->read_buf = heap_alloc( size ))) return E_OUTOFMEMORY;
if (!(channel->read_buf = malloc( size ))) return E_OUTOFMEMORY;
channel->read_buflen = size;
return S_OK;
}
......@@ -1841,7 +1840,7 @@ static HRESULT resize_read_buffer( struct channel *channel, ULONG size )
{
char *tmp;
ULONG new_size = max( size, channel->read_buflen * 2 );
if (!(tmp = heap_realloc( channel->read_buf, new_size ))) return E_OUTOFMEMORY;
if (!(tmp = realloc( channel->read_buf, new_size ))) return E_OUTOFMEMORY;
channel->read_buf = tmp;
channel->read_buflen = new_size;
}
......@@ -2064,14 +2063,14 @@ static HRESULT receive_preamble( struct channel *channel )
unsigned char *url;
if ((hr = receive_size( channel, &size )) != S_OK) return hr;
if (!(url = heap_alloc( size ))) return E_OUTOFMEMORY;
if (!(url = malloc( size ))) return E_OUTOFMEMORY;
if ((hr = receive_bytes( channel, url, size )) != S_OK)
{
heap_free( url );
free( url );
return hr;
}
TRACE( "transport URL %s\n", debugstr_an((char *)url, size) );
heap_free( url ); /* FIXME: verify */
free( url ); /* FIXME: verify */
break;
}
case FRAME_RECORD_TYPE_KNOWN_ENCODING:
......@@ -2175,7 +2174,7 @@ static HRESULT build_dict( const BYTE *buf, ULONG buflen, struct dictionary *dic
return WS_E_INVALID_FORMAT;
}
buflen -= size;
if (!(bytes = heap_alloc( size )))
if (!(bytes = malloc( size )))
{
hr = E_OUTOFMEMORY;
goto error;
......@@ -2183,13 +2182,13 @@ static HRESULT build_dict( const BYTE *buf, ULONG buflen, struct dictionary *dic
memcpy( bytes, ptr, size );
if ((index = find_string( dict, bytes, size, NULL )) == -1) /* duplicate */
{
heap_free( bytes );
free( bytes );
ptr += size;
continue;
}
if ((hr = insert_string( dict, bytes, size, index, NULL )) != S_OK)
{
heap_free( bytes );
free( bytes );
clear_dict( dict );
return hr;
}
......@@ -2375,7 +2374,7 @@ static HRESULT queue_receive_message( struct channel *channel, WS_MESSAGE *msg,
{
struct receive_message *r;
if (!(r = heap_alloc( sizeof(*r) ))) return E_OUTOFMEMORY;
if (!(r = malloc( sizeof(*r) ))) return E_OUTOFMEMORY;
r->task.proc = receive_message_proc;
r->channel = channel;
r->msg = msg;
......@@ -2485,7 +2484,7 @@ static HRESULT queue_request_reply( struct channel *channel, WS_MESSAGE *request
{
struct request_reply *r;
if (!(r = heap_alloc( sizeof(*r) ))) return E_OUTOFMEMORY;
if (!(r = malloc( sizeof(*r) ))) return E_OUTOFMEMORY;
r->task.proc = request_reply_proc;
r->channel = channel;
r->request = request;
......@@ -2583,7 +2582,7 @@ static HRESULT queue_read_message_start( struct channel *channel, WS_MESSAGE *ms
{
struct read_message_start *r;
if (!(r = heap_alloc( sizeof(*r) ))) return E_OUTOFMEMORY;
if (!(r = malloc( sizeof(*r) ))) return E_OUTOFMEMORY;
r->task.proc = read_message_start_proc;
r->channel = channel;
r->msg = msg;
......@@ -2660,7 +2659,7 @@ static HRESULT queue_read_message_end( struct channel *channel, WS_MESSAGE *msg,
{
struct read_message_end *r;
if (!(r = heap_alloc( sizeof(*r) ))) return E_OUTOFMEMORY;
if (!(r = malloc( sizeof(*r) ))) return E_OUTOFMEMORY;
r->task.proc = read_message_end_proc;
r->msg = msg;
r->ctx = *ctx;
......@@ -2735,7 +2734,7 @@ static HRESULT queue_write_message_start( struct channel *channel, WS_MESSAGE *m
{
struct write_message_start *w;
if (!(w = heap_alloc( sizeof(*w) ))) return E_OUTOFMEMORY;
if (!(w = malloc( sizeof(*w) ))) return E_OUTOFMEMORY;
w->task.proc = write_message_start_proc;
w->channel = channel;
w->msg = msg;
......@@ -2815,7 +2814,7 @@ static HRESULT queue_write_message_end( struct channel *channel, WS_MESSAGE *msg
{
struct write_message_start *w;
if (!(w = heap_alloc( sizeof(*w) ))) return E_OUTOFMEMORY;
if (!(w = malloc( sizeof(*w) ))) return E_OUTOFMEMORY;
w->task.proc = write_message_end_proc;
w->channel = channel;
w->msg = msg;
......
......@@ -17,6 +17,7 @@
*/
#include <stdarg.h>
#include <stdlib.h>
#include "windef.h"
#include "winbase.h"
......@@ -24,7 +25,6 @@
#include "webservices.h"
#include "wine/debug.h"
#include "wine/heap.h"
#include "wine/list.h"
#include "webservices_private.h"
......@@ -53,7 +53,7 @@ static struct error *alloc_error(void)
struct error *ret;
ULONG size = sizeof(*ret) + prop_size( error_props, count );
if (!(ret = heap_alloc_zero( size ))) return NULL;
if (!(ret = calloc( 1, size ))) return NULL;
ret->magic = ERROR_MAGIC;
InitializeCriticalSection( &ret->cs );
......@@ -68,7 +68,7 @@ static void free_error( struct error *error )
{
error->cs.DebugInfo->Spare[0] = 0;
DeleteCriticalSection( &error->cs );
heap_free( error );
free( error );
}
/**************************************************************************
......
......@@ -17,6 +17,7 @@
*/
#include <stdarg.h>
#include <stdlib.h>
#include "windef.h"
#include "winbase.h"
......@@ -24,7 +25,6 @@
#include "webservices.h"
#include "wine/debug.h"
#include "wine/heap.h"
#include "wine/list.h"
#include "webservices_private.h"
......@@ -181,7 +181,7 @@ static struct heap *alloc_heap(void)
struct heap *ret;
ULONG size = sizeof(*ret) + prop_size( heap_props, count );
if (!(ret = heap_alloc_zero( size ))) return NULL;
if (!(ret = calloc( 1, size ))) return NULL;
ret->magic = HEAP_MAGIC;
InitializeCriticalSection( &ret->cs );
......@@ -247,7 +247,7 @@ void WINAPI WsFreeHeap( WS_HEAP *handle )
heap->cs.DebugInfo->Spare[0] = 0;
DeleteCriticalSection( &heap->cs );
heap_free( heap );
free( heap );
}
/**************************************************************************
......
......@@ -24,7 +24,6 @@
#include "webservices.h"
#include "wine/debug.h"
#include "wine/heap.h"
#include "wine/list.h"
#include "webservices_private.h"
#include "sock.h"
......@@ -128,18 +127,18 @@ static struct listener *alloc_listener(void)
struct listener *ret;
ULONG size = sizeof(*ret) + prop_size( listener_props, count );
if (!(ret = heap_alloc_zero( size ))) return NULL;
if (!(ret = calloc( 1, size ))) return NULL;
ret->magic = LISTENER_MAGIC;
if (!(ret->wait = CreateEventW( NULL, FALSE, FALSE, NULL )))
{
heap_free( ret );
free( ret );
return NULL;
}
if (!(ret->cancel = CreateEventW( NULL, FALSE, FALSE, NULL )))
{
CloseHandle( ret->wait );
heap_free( ret );
free( ret );
return NULL;
}
InitializeCriticalSection( &ret->cs );
......@@ -181,7 +180,7 @@ static void free_listener( struct listener *listener )
listener->cs.DebugInfo->Spare[0] = 0;
DeleteCriticalSection( &listener->cs );
heap_free( listener );
free( listener );
}
static HRESULT create_listener( WS_CHANNEL_TYPE type, WS_CHANNEL_BINDING binding,
......@@ -327,7 +326,7 @@ HRESULT parse_url( const WS_STRING *str, WS_URL_SCHEME_TYPE *scheme, WCHAR **hos
if (url->host.length == 1 && (url->host.chars[0] == '+' || url->host.chars[0] == '*')) *host = NULL;
else
{
if (!(*host = heap_alloc( (url->host.length + 1) * sizeof(WCHAR) )))
if (!(*host = malloc( (url->host.length + 1) * sizeof(WCHAR) )))
{
WsFreeHeap( heap );
return E_OUTOFMEMORY;
......@@ -355,14 +354,14 @@ static HRESULT open_listener_tcp( struct listener *listener, const WS_STRING *ur
if ((hr = parse_url( url, &scheme, &host, &port )) != S_OK) return hr;
if (scheme != WS_URL_NETTCP_SCHEME_TYPE)
{
heap_free( host );
free( host );
return WS_E_INVALID_ENDPOINT_URL;
}
winsock_init();
hr = resolve_hostname( host, port, addr, &addr_len, AI_PASSIVE );
heap_free( host );
free( host );
if (hr != S_OK) return hr;
if ((listener->u.tcp.socket = socket( addr->sa_family, SOCK_STREAM, 0 )) == -1)
......@@ -406,14 +405,14 @@ static HRESULT open_listener_udp( struct listener *listener, const WS_STRING *ur
if ((hr = parse_url( url, &scheme, &host, &port )) != S_OK) return hr;
if (scheme != WS_URL_SOAPUDP_SCHEME_TYPE)
{
heap_free( host );
free( host );
return WS_E_INVALID_ENDPOINT_URL;
}
winsock_init();
hr = resolve_hostname( host, port, addr, &addr_len, AI_PASSIVE );
heap_free( host );
free( host );
if (hr != S_OK) return hr;
if ((listener->u.udp.socket = socket( addr->sa_family, SOCK_DGRAM, 0 )) == -1)
......
......@@ -17,6 +17,7 @@
*/
#include <stdarg.h>
#include <stdlib.h>
#include "windef.h"
#include "winbase.h"
......@@ -25,7 +26,6 @@
#include "webservices.h"
#include "wine/debug.h"
#include "wine/heap.h"
#include "wine/list.h"
#include "webservices_private.h"
......@@ -94,10 +94,10 @@ static struct msg *alloc_msg(void)
struct msg *ret;
ULONG size = sizeof(*ret) + prop_size( msg_props, count );
if (!(ret = heap_alloc_zero( size ))) return NULL;
if (!(ret->header = heap_alloc( HEADER_ARRAY_SIZE * sizeof(struct header *) )))
if (!(ret = calloc( 1, size ))) return NULL;
if (!(ret->header = malloc( HEADER_ARRAY_SIZE * sizeof(struct header *) )))
{
heap_free( ret );
free( ret );
return NULL;
}
ret->magic = MSG_MAGIC;
......@@ -114,10 +114,10 @@ static struct msg *alloc_msg(void)
static void free_header( struct header *header )
{
heap_free( header->name.bytes );
heap_free( header->ns.bytes );
free( header->name.bytes );
free( header->ns.bytes );
if (header->mapped) free_xml_string( header->u.text );
heap_free( header );
free( header );
}
static void reset_msg( struct msg *msg )
......@@ -129,7 +129,7 @@ static void reset_msg( struct msg *msg )
UuidCreate( &msg->id );
memset( &msg->id_req, 0, sizeof(msg->id_req) );
msg->is_addressed = FALSE;
heap_free( msg->addr.chars );
free( msg->addr.chars );
msg->addr.chars = NULL;
msg->addr.length = 0;
......@@ -159,11 +159,11 @@ static void free_msg( struct msg *msg )
WsFreeWriter( msg->writer );
WsFreeReader( msg->reader );
WsFreeHeap( msg->heap );
heap_free( msg->header );
free( msg->header );
msg->cs.DebugInfo->Spare[0] = 0;
DeleteCriticalSection( &msg->cs );
heap_free( msg );
free( msg );
}
#define HEAP_MAX_SIZE (1 << 16)
......@@ -454,7 +454,7 @@ HRESULT WINAPI WsAddressMessage( WS_MESSAGE *handle, const WS_ENDPOINT_ADDRESS *
if (msg->state < WS_MESSAGE_STATE_INITIALIZED || msg->is_addressed) hr = WS_E_INVALID_OPERATION;
else if (addr && addr->url.length)
{
if (!(msg->addr.chars = heap_alloc( addr->url.length * sizeof(WCHAR) ))) hr = E_OUTOFMEMORY;
if (!(msg->addr.chars = malloc( addr->url.length * sizeof(WCHAR) ))) hr = E_OUTOFMEMORY;
else
{
memcpy( msg->addr.chars, addr->url.chars, addr->url.length * sizeof(WCHAR) );
......@@ -1101,8 +1101,7 @@ static HRESULT grow_header_array( struct msg *msg, ULONG size )
{
struct header **tmp;
if (size <= msg->header_size) return S_OK;
if (!(tmp = heap_realloc( msg->header, 2 * msg->header_size * sizeof(struct header *) )))
return E_OUTOFMEMORY;
if (!(tmp = realloc( msg->header, 2 * msg->header_size * sizeof(struct header *) ))) return E_OUTOFMEMORY;
msg->header = tmp;
msg->header_size *= 2;
return S_OK;
......@@ -1112,10 +1111,10 @@ static struct header *alloc_header( WS_HEADER_TYPE type, BOOL mapped, const WS_X
const WS_XML_STRING *ns )
{
struct header *ret;
if (!(ret = heap_alloc_zero( sizeof(*ret) ))) return NULL;
if (!(ret = calloc( 1, sizeof(*ret) ))) return NULL;
if (name && name->length)
{
if (!(ret->name.bytes = heap_alloc( name->length )))
if (!(ret->name.bytes = malloc( name->length )))
{
free_header( ret );
return NULL;
......@@ -1125,7 +1124,7 @@ static struct header *alloc_header( WS_HEADER_TYPE type, BOOL mapped, const WS_X
}
if (ns && ns->length)
{
if (!(ret->ns.bytes = heap_alloc( ns->length )))
if (!(ret->ns.bytes = malloc( ns->length )))
{
free_header( ret );
return NULL;
......@@ -1845,7 +1844,7 @@ HRESULT WINAPI WsRemoveCustomHeader( WS_MESSAGE *handle, const WS_XML_STRING *na
static WCHAR *build_http_header( const WCHAR *name, const WCHAR *value, ULONG *ret_len )
{
int len_name = lstrlenW( name ), len_value = lstrlenW( value );
WCHAR *ret = heap_alloc( (len_name + len_value + 2) * sizeof(WCHAR) );
WCHAR *ret = malloc( (len_name + len_value + 2) * sizeof(WCHAR) );
if (!ret) return NULL;
memcpy( ret, name, len_name * sizeof(WCHAR) );
......@@ -1866,7 +1865,7 @@ static WCHAR *from_xml_string( const WS_XML_STRING *str )
{
WCHAR *ret;
int len = MultiByteToWideChar( CP_UTF8, 0, (char *)str->bytes, str->length, NULL, 0 );
if (!(ret = heap_alloc( (len + 1) * sizeof(*ret) ))) return NULL;
if (!(ret = malloc( (len + 1) * sizeof(*ret) ))) return NULL;
MultiByteToWideChar( CP_UTF8, 0, (char *)str->bytes, str->length, ret, len );
ret[len] = 0;
return ret;
......@@ -1885,16 +1884,16 @@ static HRESULT insert_mapped_headers( struct msg *msg, HINTERNET req )
if (!(name = from_xml_string( &msg->header[i]->name ))) return E_OUTOFMEMORY;
if (!(value = from_xml_string( msg->header[i]->u.text )))
{
heap_free( name );
free( name );
return E_OUTOFMEMORY;
}
header = build_http_header( name, value, &len );
heap_free( name );
heap_free( value );
free( name );
free( value );
if (!header) return E_OUTOFMEMORY;
hr = insert_http_header( req, header, len, WINHTTP_ADDREQ_FLAG_ADD|WINHTTP_ADDREQ_FLAG_REPLACE );
heap_free( header );
free( header );
if (hr != S_OK) return hr;
}
return S_OK;
......@@ -1932,13 +1931,13 @@ HRESULT message_insert_http_headers( WS_MESSAGE *handle, HINTERNET req )
if (!header) goto done;
if ((hr = insert_http_header( req, header, len, WINHTTP_ADDREQ_FLAG_ADD )) != S_OK) goto done;
heap_free( header );
free( header );
hr = E_OUTOFMEMORY;
if (!(header = build_http_header( L"Content-Type", L"charset=utf-8", &len ))) goto done;
if ((hr = insert_http_header( req, header, len, WINHTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON )) != S_OK)
goto done;
heap_free( header );
free( header );
header = NULL;
switch (msg->version_env)
......@@ -1949,14 +1948,14 @@ HRESULT message_insert_http_headers( WS_MESSAGE *handle, HINTERNET req )
break;
hr = E_OUTOFMEMORY;
if (!(buf = heap_alloc( (len + 3) * sizeof(WCHAR) ))) goto done;
if (!(buf = malloc( (len + 3) * sizeof(WCHAR) ))) goto done;
buf[0] = '"';
MultiByteToWideChar( CP_UTF8, 0, (char *)msg->action->bytes, msg->action->length, buf + 1, len );
buf[len + 1] = '"';
buf[len + 2] = 0;
header = build_http_header( L"SOAPAction", buf, &len );
heap_free( buf );
free( buf );
if (!header) goto done;
hr = insert_http_header( req, header, len, WINHTTP_ADDREQ_FLAG_ADD );
......@@ -1970,7 +1969,7 @@ HRESULT message_insert_http_headers( WS_MESSAGE *handle, HINTERNET req )
break;
hr = E_OUTOFMEMORY;
if (!(buf = heap_alloc( (len + len_action + 2) * sizeof(WCHAR) ))) goto done;
if (!(buf = malloc( (len + len_action + 2) * sizeof(WCHAR) ))) goto done;
memcpy( buf, L"action=\"", len_action * sizeof(WCHAR) );
MultiByteToWideChar( CP_UTF8, 0, (char *)msg->action->bytes, msg->action->length, buf + len_action, len );
len += len_action;
......@@ -1978,7 +1977,7 @@ HRESULT message_insert_http_headers( WS_MESSAGE *handle, HINTERNET req )
buf[len] = 0;
header = build_http_header( L"Content-Type", buf, &len );
heap_free( buf );
free( buf );
if (!header) goto done;
hr = insert_http_header( req, header, len, WINHTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON );
......@@ -1992,7 +1991,7 @@ HRESULT message_insert_http_headers( WS_MESSAGE *handle, HINTERNET req )
if (hr == S_OK) hr = insert_mapped_headers( msg, req );
done:
heap_free( header );
free( header );
LeaveCriticalSection( &msg->cs );
TRACE( "returning %08x\n", hr );
return hr;
......@@ -2012,26 +2011,26 @@ static HRESULT map_http_response_headers( struct msg *msg, HINTERNET req, const
GetLastError() == ERROR_INSUFFICIENT_BUFFER)
{
HRESULT hr;
if (!(value = heap_alloc( size )))
if (!(value = malloc( size )))
{
heap_free( name );
free( name );
return E_OUTOFMEMORY;
}
if (!WinHttpQueryHeaders( req, WINHTTP_QUERY_CUSTOM, name, value, &size, NULL ))
{
heap_free( name );
free( name );
return HRESULT_FROM_WIN32( GetLastError() );
}
hr = add_mapped_header( msg, &mapping->responseHeaderMappings[i]->headerName, WS_WSZ_TYPE,
WS_WRITE_REQUIRED_POINTER, &value, sizeof(value) );
heap_free( value );
free( value );
if (hr != S_OK)
{
heap_free( name );
free( name );
return hr;
}
}
heap_free( name );
free( name );
}
return S_OK;
}
......
......@@ -17,6 +17,7 @@
*/
#include <stdarg.h>
#include <stdlib.h>
#include "windef.h"
#include "winbase.h"
......@@ -24,7 +25,6 @@
#include "webservices.h"
#include "wine/debug.h"
#include "wine/heap.h"
#include "wine/list.h"
#include "webservices_private.h"
......@@ -59,7 +59,7 @@ static struct proxy *alloc_proxy(void)
struct proxy *ret;
ULONG size = sizeof(*ret) + prop_size( proxy_props, count );
if (!(ret = heap_alloc_zero( size ))) return NULL;
if (!(ret = calloc( 1, size ))) return NULL;
ret->magic = PROXY_MAGIC;
InitializeCriticalSection( &ret->cs );
......@@ -83,7 +83,7 @@ static void free_proxy( struct proxy *proxy )
proxy->cs.DebugInfo->Spare[0] = 0;
DeleteCriticalSection( &proxy->cs );
heap_free( proxy );
free( proxy );
}
static HRESULT create_proxy( WS_CHANNEL *channel, const WS_PROXY_PROPERTY *properties, ULONG count,
......
......@@ -17,6 +17,7 @@
*/
#include <stdarg.h>
#include <stdlib.h>
#include <assert.h>
#include <float.h>
#include <locale.h>
......@@ -27,7 +28,6 @@
#include "webservices.h"
#include "wine/debug.h"
#include "wine/heap.h"
#include "wine/list.h"
#include "webservices_private.h"
......@@ -72,7 +72,7 @@ struct node *alloc_node( WS_XML_NODE_TYPE type )
{
struct node *ret;
if (!(ret = heap_alloc_zero( sizeof(*ret) ))) return NULL;
if (!(ret = calloc( 1, sizeof(*ret) ))) return NULL;
ret->hdr.node.nodeType = type;
list_init( &ret->entry );
list_init( &ret->children );
......@@ -85,8 +85,8 @@ void free_attribute( WS_XML_ATTRIBUTE *attr )
free_xml_string( attr->prefix );
free_xml_string( attr->localName );
free_xml_string( attr->ns );
heap_free( attr->value );
heap_free( attr );
free( attr->value );
free( attr );
}
void free_node( struct node *node )
......@@ -100,7 +100,7 @@ void free_node( struct node *node )
ULONG i;
for (i = 0; i < elem->attributeCount; i++) free_attribute( elem->attributes[i] );
heap_free( elem->attributes );
free( elem->attributes );
free_xml_string( elem->prefix );
free_xml_string( elem->localName );
free_xml_string( elem->ns );
......@@ -109,13 +109,13 @@ void free_node( struct node *node )
case WS_XML_NODE_TYPE_TEXT:
{
WS_XML_TEXT_NODE *text = (WS_XML_TEXT_NODE *)node;
heap_free( text->text );
free( text->text );
break;
}
case WS_XML_NODE_TYPE_COMMENT:
{
WS_XML_COMMENT_NODE *comment = (WS_XML_COMMENT_NODE *)node;
heap_free( comment->value.bytes );
free( comment->value.bytes );
break;
}
case WS_XML_NODE_TYPE_CDATA:
......@@ -129,7 +129,7 @@ void free_node( struct node *node )
ERR( "unhandled type %u\n", node_type( node ) );
break;
}
heap_free( node );
free( node );
}
void destroy_nodes( struct node *node )
......@@ -151,7 +151,7 @@ static WS_XML_ATTRIBUTE *dup_attribute( const WS_XML_ATTRIBUTE *src, WS_XML_WRIT
WS_XML_ATTRIBUTE *dst;
HRESULT hr;
if (!(dst = heap_alloc_zero( sizeof(*dst) ))) return NULL;
if (!(dst = calloc( 1, sizeof(*dst) ))) return NULL;
dst->singleQuote = src->singleQuote;
dst->isXmlNs = src->isXmlNs;
......@@ -191,13 +191,13 @@ static WS_XML_ATTRIBUTE **dup_attributes( WS_XML_ATTRIBUTE * const *src, ULONG c
WS_XML_ATTRIBUTE **dst;
ULONG i;
if (!(dst = heap_alloc( sizeof(*dst) * count ))) return NULL;
if (!(dst = malloc( sizeof(*dst) * count ))) return NULL;
for (i = 0; i < count; i++)
{
if (!(dst[i] = dup_attribute( src[i], enc )))
{
for (; i > 0; i--) free_attribute( dst[i - 1] );
heap_free( dst );
free( dst );
return NULL;
}
}
......@@ -273,7 +273,7 @@ static struct node *dup_comment_node( const WS_XML_COMMENT_NODE *src )
if (!(node = alloc_node( WS_XML_NODE_TYPE_COMMENT ))) return NULL;
dst = (WS_XML_COMMENT_NODE *)node;
if (src->value.length && !(dst->value.bytes = heap_alloc( src->value.length )))
if (src->value.length && !(dst->value.bytes = malloc( src->value.length )))
{
free_node( node );
return NULL;
......@@ -413,10 +413,10 @@ static struct reader *alloc_reader(void)
struct reader *ret;
ULONG size = sizeof(*ret) + prop_size( reader_props, count );
if (!(ret = heap_alloc_zero( size ))) return NULL;
if (!(ret->prefixes = heap_alloc_zero( sizeof(*ret->prefixes) )))
if (!(ret = calloc( 1, size ))) return NULL;
if (!(ret->prefixes = calloc( 1, sizeof(*ret->prefixes) )))
{
heap_free( ret );
free( ret );
return NULL;
}
ret->nb_prefixes = ret->nb_prefixes_allocated = 1;
......@@ -466,11 +466,12 @@ static HRESULT bind_prefix( struct reader *reader, const WS_XML_STRING *prefix,
}
if (i >= reader->nb_prefixes_allocated)
{
ULONG new_size = reader->nb_prefixes_allocated * sizeof(*reader->prefixes) * 2;
struct prefix *tmp = heap_realloc_zero( reader->prefixes, new_size );
ULONG new_size = reader->nb_prefixes_allocated * 2;
struct prefix *tmp = realloc( reader->prefixes, new_size * sizeof(*tmp) );
if (!tmp) return E_OUTOFMEMORY;
memset( tmp + reader->nb_prefixes_allocated, 0, (new_size - reader->nb_prefixes_allocated) * sizeof(*tmp) );
reader->prefixes = tmp;
reader->nb_prefixes_allocated *= 2;
reader->nb_prefixes_allocated = new_size;
}
if ((hr = set_prefix( &reader->prefixes[i], prefix, ns )) != S_OK) return hr;
reader->nb_prefixes++;
......@@ -517,13 +518,13 @@ static void free_reader( struct reader *reader )
{
destroy_nodes( reader->root );
clear_prefixes( reader->prefixes, reader->nb_prefixes );
heap_free( reader->prefixes );
heap_free( reader->stream_buf );
heap_free( reader->input_conv );
free( reader->prefixes );
free( reader->stream_buf );
free( reader->input_conv );
reader->cs.DebugInfo->Spare[0] = 0;
DeleteCriticalSection( &reader->cs );
heap_free( reader );
free( reader );
}
static HRESULT init_reader( struct reader *reader )
......@@ -839,7 +840,7 @@ WS_XML_UTF8_TEXT *alloc_utf8_text( const BYTE *data, ULONG len )
{
WS_XML_UTF8_TEXT *ret;
if (!(ret = heap_alloc( sizeof(*ret) + len ))) return NULL;
if (!(ret = malloc( sizeof(*ret) + len ))) return NULL;
ret->text.textType = WS_XML_TEXT_TYPE_UTF8;
ret->value.length = len;
ret->value.bytes = len ? (BYTE *)(ret + 1) : NULL;
......@@ -853,7 +854,7 @@ WS_XML_UTF16_TEXT *alloc_utf16_text( const BYTE *data, ULONG len )
{
WS_XML_UTF16_TEXT *ret;
if (!(ret = heap_alloc( sizeof(*ret) + len ))) return NULL;
if (!(ret = malloc( sizeof(*ret) + len ))) return NULL;
ret->text.textType = WS_XML_TEXT_TYPE_UTF16;
ret->byteCount = len;
ret->bytes = len ? (BYTE *)(ret + 1) : NULL;
......@@ -865,7 +866,7 @@ WS_XML_BASE64_TEXT *alloc_base64_text( const BYTE *data, ULONG len )
{
WS_XML_BASE64_TEXT *ret;
if (!(ret = heap_alloc( sizeof(*ret) + len ))) return NULL;
if (!(ret = malloc( sizeof(*ret) + len ))) return NULL;
ret->text.textType = WS_XML_TEXT_TYPE_BASE64;
ret->length = len;
ret->bytes = len ? (BYTE *)(ret + 1) : NULL;
......@@ -877,7 +878,7 @@ WS_XML_BOOL_TEXT *alloc_bool_text( BOOL value )
{
WS_XML_BOOL_TEXT *ret;
if (!(ret = heap_alloc( sizeof(*ret) ))) return NULL;
if (!(ret = malloc( sizeof(*ret) ))) return NULL;
ret->text.textType = WS_XML_TEXT_TYPE_BOOL;
ret->value = value;
return ret;
......@@ -887,7 +888,7 @@ WS_XML_INT32_TEXT *alloc_int32_text( INT32 value )
{
WS_XML_INT32_TEXT *ret;
if (!(ret = heap_alloc( sizeof(*ret) ))) return NULL;
if (!(ret = malloc( sizeof(*ret) ))) return NULL;
ret->text.textType = WS_XML_TEXT_TYPE_INT32;
ret->value = value;
return ret;
......@@ -897,7 +898,7 @@ WS_XML_INT64_TEXT *alloc_int64_text( INT64 value )
{
WS_XML_INT64_TEXT *ret;
if (!(ret = heap_alloc( sizeof(*ret) ))) return NULL;
if (!(ret = malloc( sizeof(*ret) ))) return NULL;
ret->text.textType = WS_XML_TEXT_TYPE_INT64;
ret->value = value;
return ret;
......@@ -907,7 +908,7 @@ WS_XML_UINT64_TEXT *alloc_uint64_text( UINT64 value )
{
WS_XML_UINT64_TEXT *ret;
if (!(ret = heap_alloc( sizeof(*ret) ))) return NULL;
if (!(ret = malloc( sizeof(*ret) ))) return NULL;
ret->text.textType = WS_XML_TEXT_TYPE_UINT64;
ret->value = value;
return ret;
......@@ -917,7 +918,7 @@ WS_XML_FLOAT_TEXT *alloc_float_text( float value )
{
WS_XML_FLOAT_TEXT *ret;
if (!(ret = heap_alloc( sizeof(*ret) ))) return NULL;
if (!(ret = malloc( sizeof(*ret) ))) return NULL;
ret->text.textType = WS_XML_TEXT_TYPE_FLOAT;
ret->value = value;
return ret;
......@@ -927,7 +928,7 @@ WS_XML_DOUBLE_TEXT *alloc_double_text( double value )
{
WS_XML_DOUBLE_TEXT *ret;
if (!(ret = heap_alloc( sizeof(*ret) ))) return NULL;
if (!(ret = malloc( sizeof(*ret) ))) return NULL;
ret->text.textType = WS_XML_TEXT_TYPE_DOUBLE;
ret->value = value;
return ret;
......@@ -937,7 +938,7 @@ WS_XML_GUID_TEXT *alloc_guid_text( const GUID *value )
{
WS_XML_GUID_TEXT *ret;
if (!(ret = heap_alloc( sizeof(*ret) ))) return NULL;
if (!(ret = malloc( sizeof(*ret) ))) return NULL;
ret->text.textType = WS_XML_TEXT_TYPE_GUID;
ret->value = *value;
return ret;
......@@ -947,7 +948,7 @@ WS_XML_UNIQUE_ID_TEXT *alloc_unique_id_text( const GUID *value )
{
WS_XML_UNIQUE_ID_TEXT *ret;
if (!(ret = heap_alloc( sizeof(*ret) ))) return NULL;
if (!(ret = malloc( sizeof(*ret) ))) return NULL;
ret->text.textType = WS_XML_TEXT_TYPE_UNIQUE_ID;
ret->value = *value;
return ret;
......@@ -957,7 +958,7 @@ WS_XML_DATETIME_TEXT *alloc_datetime_text( const WS_DATETIME *value )
{
WS_XML_DATETIME_TEXT *ret;
if (!(ret = heap_alloc( sizeof(*ret) ))) return NULL;
if (!(ret = malloc( sizeof(*ret) ))) return NULL;
ret->text.textType = WS_XML_TEXT_TYPE_DATETIME;
ret->value = *value;
return ret;
......@@ -1138,11 +1139,10 @@ HRESULT append_attribute( WS_XML_ELEMENT_NODE *elem, WS_XML_ATTRIBUTE *attr )
if (elem->attributeCount)
{
WS_XML_ATTRIBUTE **tmp;
if (!(tmp = heap_realloc( elem->attributes, (elem->attributeCount + 1) * sizeof(attr) )))
return E_OUTOFMEMORY;
if (!(tmp = realloc( elem->attributes, (elem->attributeCount + 1) * sizeof(attr) ))) return E_OUTOFMEMORY;
elem->attributes = tmp;
}
else if (!(elem->attributes = heap_alloc( sizeof(attr) ))) return E_OUTOFMEMORY;
else if (!(elem->attributes = malloc( sizeof(attr) ))) return E_OUTOFMEMORY;
elem->attributes[elem->attributeCount++] = attr;
return S_OK;
}
......@@ -1377,7 +1377,7 @@ static HRESULT read_attribute_value_text( struct reader *reader, WS_XML_ATTRIBUT
if (!(utf8 = alloc_utf8_text( NULL, len ))) return E_OUTOFMEMORY;
if ((hr = decode_text( start, len, utf8->value.bytes, &utf8->value.length )) != S_OK)
{
heap_free( utf8 );
free( utf8 );
return hr;
}
}
......@@ -1596,7 +1596,7 @@ static HRESULT read_attribute_value_bin( struct reader *reader, WS_XML_ATTRIBUTE
if (!(text_base64 = alloc_base64_text( NULL, val_uint8 ))) return E_OUTOFMEMORY;
if ((hr = read_bytes( reader, text_base64->bytes, val_uint8 )) != S_OK)
{
heap_free( text_base64 );
free( text_base64 );
return hr;
}
break;
......@@ -1606,7 +1606,7 @@ static HRESULT read_attribute_value_bin( struct reader *reader, WS_XML_ATTRIBUTE
if (!(text_base64 = alloc_base64_text( NULL, val_uint16 ))) return E_OUTOFMEMORY;
if ((hr = read_bytes( reader, text_base64->bytes, val_uint16 )) != S_OK)
{
heap_free( text_base64 );
free( text_base64 );
return hr;
}
break;
......@@ -1617,7 +1617,7 @@ static HRESULT read_attribute_value_bin( struct reader *reader, WS_XML_ATTRIBUTE
if (!(text_base64 = alloc_base64_text( NULL, val_int32 ))) return E_OUTOFMEMORY;
if ((hr = read_bytes( reader, text_base64->bytes, val_int32 )) != S_OK)
{
heap_free( text_base64 );
free( text_base64 );
return hr;
}
break;
......@@ -1684,7 +1684,7 @@ static HRESULT read_attribute_value_bin( struct reader *reader, WS_XML_ATTRIBUTE
if (!len) text_utf8->value.bytes = (BYTE *)(text_utf8 + 1); /* quirk */
if ((hr = read_bytes( reader, text_utf8->value.bytes, len )) != S_OK)
{
heap_free( text_utf8 );
free( text_utf8 );
return hr;
}
}
......@@ -1702,7 +1702,7 @@ static HRESULT read_attribute_text( struct reader *reader, WS_XML_ATTRIBUTE **re
WS_XML_STRING *prefix, *localname;
HRESULT hr;
if (!(attr = heap_alloc_zero( sizeof(*attr) ))) return E_OUTOFMEMORY;
if (!(attr = calloc( 1, sizeof(*attr) ))) return E_OUTOFMEMORY;
start = read_current_ptr( reader );
for (;;)
......@@ -1773,7 +1773,7 @@ static HRESULT read_attribute_bin( struct reader *reader, WS_XML_ATTRIBUTE **ret
if ((hr = read_byte( reader, &type )) != S_OK) return hr;
if (!is_attribute_type( type )) return WS_E_INVALID_FORMAT;
if (!(attr = heap_alloc_zero( sizeof(*attr) ))) return E_OUTOFMEMORY;
if (!(attr = calloc( 1, sizeof(*attr) ))) return E_OUTOFMEMORY;
if (type >= RECORD_PREFIX_ATTRIBUTE_A && type <= RECORD_PREFIX_ATTRIBUTE_Z)
{
......@@ -2175,13 +2175,13 @@ static HRESULT read_text_text( struct reader *reader )
text = (WS_XML_TEXT_NODE *)node;
if (!(utf8 = alloc_utf8_text( NULL, len )))
{
heap_free( node );
free( node );
return E_OUTOFMEMORY;
}
if ((hr = decode_text( start, len, utf8->value.bytes, &utf8->value.length )) != S_OK)
{
heap_free( utf8 );
heap_free( node );
free( utf8 );
free( node );
return hr;
}
text->text = &utf8->text;
......@@ -2201,7 +2201,7 @@ static struct node *alloc_utf8_text_node( const BYTE *data, ULONG len, WS_XML_UT
if (!(node = alloc_node( WS_XML_NODE_TYPE_TEXT ))) return NULL;
if (!(utf8 = alloc_utf8_text( data, len )))
{
heap_free( node );
free( node );
return NULL;
}
text = (WS_XML_TEXT_NODE *)node;
......@@ -2219,7 +2219,7 @@ static struct node *alloc_base64_text_node( const BYTE *data, ULONG len, WS_XML_
if (!(node = alloc_node( WS_XML_NODE_TYPE_TEXT ))) return NULL;
if (!(base64 = alloc_base64_text( data, len )))
{
heap_free( node );
free( node );
return NULL;
}
text = (WS_XML_TEXT_NODE *)node;
......@@ -2237,7 +2237,7 @@ static struct node *alloc_bool_text_node( BOOL value )
if (!(node = alloc_node( WS_XML_NODE_TYPE_TEXT ))) return NULL;
if (!(text_bool = alloc_bool_text( value )))
{
heap_free( node );
free( node );
return NULL;
}
text = (WS_XML_TEXT_NODE *)node;
......@@ -2254,7 +2254,7 @@ static struct node *alloc_int32_text_node( INT32 value )
if (!(node = alloc_node( WS_XML_NODE_TYPE_TEXT ))) return NULL;
if (!(text_int32 = alloc_int32_text( value )))
{
heap_free( node );
free( node );
return NULL;
}
text = (WS_XML_TEXT_NODE *)node;
......@@ -2271,7 +2271,7 @@ static struct node *alloc_int64_text_node( INT64 value )
if (!(node = alloc_node( WS_XML_NODE_TYPE_TEXT ))) return NULL;
if (!(text_int64 = alloc_int64_text( value )))
{
heap_free( node );
free( node );
return NULL;
}
text = (WS_XML_TEXT_NODE *)node;
......@@ -2288,7 +2288,7 @@ static struct node *alloc_float_text_node( float value )
if (!(node = alloc_node( WS_XML_NODE_TYPE_TEXT ))) return NULL;
if (!(text_float = alloc_float_text( value )))
{
heap_free( node );
free( node );
return NULL;
}
text = (WS_XML_TEXT_NODE *)node;
......@@ -2305,7 +2305,7 @@ static struct node *alloc_double_text_node( double value )
if (!(node = alloc_node( WS_XML_NODE_TYPE_TEXT ))) return NULL;
if (!(text_double = alloc_double_text( value )))
{
heap_free( node );
free( node );
return NULL;
}
text = (WS_XML_TEXT_NODE *)node;
......@@ -2322,7 +2322,7 @@ static struct node *alloc_datetime_text_node( const WS_DATETIME *value )
if (!(node = alloc_node( WS_XML_NODE_TYPE_TEXT ))) return NULL;
if (!(text_datetime = alloc_datetime_text( value )))
{
heap_free( node );
free( node );
return NULL;
}
text = (WS_XML_TEXT_NODE *)node;
......@@ -2339,7 +2339,7 @@ static struct node *alloc_unique_id_text_node( const GUID *value )
if (!(node = alloc_node( WS_XML_NODE_TYPE_TEXT ))) return NULL;
if (!(text_unique_id = alloc_unique_id_text( value )))
{
heap_free( node );
free( node );
return NULL;
}
text = (WS_XML_TEXT_NODE *)node;
......@@ -2356,7 +2356,7 @@ static struct node *alloc_guid_text_node( const GUID *value )
if (!(node = alloc_node( WS_XML_NODE_TYPE_TEXT ))) return NULL;
if (!(text_guid = alloc_guid_text( value )))
{
heap_free( node );
free( node );
return NULL;
}
text = (WS_XML_TEXT_NODE *)node;
......@@ -2373,7 +2373,7 @@ static struct node *alloc_uint64_text_node( UINT64 value )
if (!(node = alloc_node( WS_XML_NODE_TYPE_TEXT ))) return NULL;
if (!(text_uint64 = alloc_uint64_text( value )))
{
heap_free( node );
free( node );
return NULL;
}
text = (WS_XML_TEXT_NODE *)node;
......@@ -2389,7 +2389,7 @@ static HRESULT append_text_bytes( struct reader *reader, WS_XML_TEXT_NODE *node,
if (!(new = alloc_base64_text( NULL, old->length + len ))) return E_OUTOFMEMORY;
memcpy( new->bytes, old->bytes, old->length );
if ((hr = read_bytes( reader, new->bytes + old->length, len )) != S_OK) return hr;
heap_free( old );
free( old );
node->text = &new->text;
return S_OK;
}
......@@ -2896,9 +2896,9 @@ static HRESULT read_comment_text( struct reader *reader )
if (!(node = alloc_node( WS_XML_NODE_TYPE_COMMENT ))) return E_OUTOFMEMORY;
comment = (WS_XML_COMMENT_NODE *)node;
if (!(comment->value.bytes = heap_alloc( len )))
if (!(comment->value.bytes = malloc( len )))
{
heap_free( node );
free( node );
return E_OUTOFMEMORY;
}
memcpy( comment->value.bytes, start, len );
......@@ -2925,9 +2925,9 @@ static HRESULT read_comment_bin( struct reader *reader )
if (!(node = alloc_node( WS_XML_NODE_TYPE_COMMENT ))) return E_OUTOFMEMORY;
comment = (WS_XML_COMMENT_NODE *)node;
if (!(comment->value.bytes = heap_alloc( len )))
if (!(comment->value.bytes = malloc( len )))
{
heap_free( node );
free( node );
return E_OUTOFMEMORY;
}
if ((hr = read_bytes( reader, comment->value.bytes, len )) != S_OK)
......@@ -2955,7 +2955,7 @@ static HRESULT read_startcdata( struct reader *reader )
if (!(node = alloc_node( WS_XML_NODE_TYPE_CDATA ))) return E_OUTOFMEMORY;
if (!(endnode = alloc_node( WS_XML_NODE_TYPE_END_CDATA )))
{
heap_free( node );
free( node );
return E_OUTOFMEMORY;
}
list_add_tail( &node->children, &endnode->entry );
......@@ -2988,7 +2988,7 @@ static HRESULT read_cdata( struct reader *reader )
text = (WS_XML_TEXT_NODE *)node;
if (!(utf8 = alloc_utf8_text( start, len )))
{
heap_free( node );
free( node );
return E_OUTOFMEMORY;
}
text->text = &utf8->text;
......@@ -6905,7 +6905,7 @@ static HRESULT utf16le_to_utf8( const unsigned char *data, ULONG size, unsigned
{
if (size % sizeof(WCHAR)) return E_INVALIDARG;
*buflen = WideCharToMultiByte( CP_UTF8, 0, (const WCHAR *)data, size / sizeof(WCHAR), NULL, 0, NULL, NULL );
if (!(*buf = heap_alloc( *buflen ))) return E_OUTOFMEMORY;
if (!(*buf = malloc( *buflen ))) return E_OUTOFMEMORY;
WideCharToMultiByte( CP_UTF8, 0, (const WCHAR *)data, size / sizeof(WCHAR), (char *)*buf, *buflen, NULL, NULL );
return S_OK;
}
......@@ -6922,7 +6922,7 @@ static HRESULT set_input_buffer( struct reader *reader, const unsigned char *dat
HRESULT hr;
if ((hr = utf16le_to_utf8( data, size, &buf, &buflen )) != S_OK) return hr;
heap_free( reader->input_conv );
free( reader->input_conv );
reader->read_bufptr = reader->input_conv = buf;
reader->read_size = reader->input_size = buflen;
}
......@@ -7032,7 +7032,7 @@ HRESULT WINAPI WsSetInput( WS_XML_READER *handle, const WS_XML_READER_ENCODING *
case WS_XML_READER_INPUT_TYPE_STREAM:
{
const WS_XML_READER_STREAM_INPUT *stream = (const WS_XML_READER_STREAM_INPUT *)input;
if (!reader->stream_buf && !(reader->stream_buf = heap_alloc( STREAM_BUFSIZE )))
if (!reader->stream_buf && !(reader->stream_buf = malloc( STREAM_BUFSIZE )))
{
hr = E_OUTOFMEMORY;
goto done;
......@@ -7071,7 +7071,7 @@ static HRESULT set_input_xml_buffer( struct reader *reader, struct xmlbuf *xmlbu
HRESULT hr;
if ((hr = utf16le_to_utf8( xmlbuf->bytes.bytes, xmlbuf->bytes.length, &buf, &buflen )) != S_OK) return hr;
heap_free( reader->input_conv );
free( reader->input_conv );
reader->read_bufptr = reader->input_conv = buf;
reader->read_size = reader->input_size = buflen;
}
......@@ -7196,7 +7196,7 @@ HRESULT WINAPI WsSetReaderPosition( WS_XML_READER *handle, const WS_XML_NODE_POS
static HRESULT utf8_to_base64( const WS_XML_UTF8_TEXT *utf8, WS_XML_BASE64_TEXT *base64 )
{
if (utf8->value.length % 4) return WS_E_INVALID_FORMAT;
if (!(base64->bytes = heap_alloc( utf8->value.length * 3 / 4 ))) return E_OUTOFMEMORY;
if (!(base64->bytes = malloc( utf8->value.length * 3 / 4 ))) return E_OUTOFMEMORY;
base64->length = decode_base64( utf8->value.bytes, utf8->value.length, base64->bytes );
return S_OK;
}
......@@ -7242,14 +7242,14 @@ HRESULT WINAPI WsReadBytes( WS_XML_READER *handle, void *bytes, ULONG max_count,
if ((hr = utf8_to_base64( (const WS_XML_UTF8_TEXT *)text->text, &base64 )) != S_OK) goto done;
if (reader->text_conv_offset == base64.length)
{
heap_free( base64.bytes );
free( base64.bytes );
hr = read_node( reader );
goto done;
}
*count = min( base64.length - reader->text_conv_offset, max_count );
memcpy( bytes, base64.bytes + reader->text_conv_offset, *count );
reader->text_conv_offset += *count;
heap_free( base64.bytes );
free( base64.bytes );
}
done:
......@@ -7261,7 +7261,7 @@ done:
static HRESULT utf8_to_utf16( const WS_XML_UTF8_TEXT *utf8, WS_XML_UTF16_TEXT *utf16 )
{
int len = MultiByteToWideChar( CP_UTF8, 0, (char *)utf8->value.bytes, utf8->value.length, NULL, 0 );
if (!(utf16->bytes = heap_alloc( len * sizeof(WCHAR) ))) return E_OUTOFMEMORY;
if (!(utf16->bytes = malloc( len * sizeof(WCHAR) ))) return E_OUTOFMEMORY;
MultiByteToWideChar( CP_UTF8, 0, (char *)utf8->value.bytes, utf8->value.length, (WCHAR *)utf16->bytes, len );
utf16->byteCount = len * sizeof(WCHAR);
return S_OK;
......@@ -7309,14 +7309,14 @@ HRESULT WINAPI WsReadChars( WS_XML_READER *handle, WCHAR *chars, ULONG max_count
if ((hr = utf8_to_utf16( (const WS_XML_UTF8_TEXT *)text->text, &utf16 )) != S_OK) goto done;
if (reader->text_conv_offset == utf16.byteCount / sizeof(WCHAR))
{
heap_free( utf16.bytes );
free( utf16.bytes );
hr = read_node( reader );
goto done;
}
*count = min( utf16.byteCount / sizeof(WCHAR) - reader->text_conv_offset, max_count );
memcpy( chars, utf16.bytes + reader->text_conv_offset * sizeof(WCHAR), *count * sizeof(WCHAR) );
reader->text_conv_offset += *count;
heap_free( utf16.bytes );
free( utf16.bytes );
}
done:
......
......@@ -17,6 +17,7 @@
*/
#include <stdarg.h>
#include <stdlib.h>
#include <assert.h>
#include "windef.h"
......@@ -24,7 +25,6 @@
#include "webservices.h"
#include "wine/debug.h"
#include "wine/heap.h"
#include "wine/list.h"
#include "webservices_private.h"
......@@ -100,18 +100,18 @@ static HRESULT grow_dict( struct dictionary *dict, ULONG size )
if (!dict->dict.strings)
{
new_size = max( MIN_DICTIONARY_SIZE, size );
if (!(dict->dict.strings = heap_alloc( new_size * sizeof(*dict->dict.strings) ))) return E_OUTOFMEMORY;
if (!(dict->sorted = heap_alloc( new_size * sizeof(*dict->sorted) )))
if (!(dict->dict.strings = malloc( new_size * sizeof(*dict->dict.strings) ))) return E_OUTOFMEMORY;
if (!(dict->sorted = malloc( new_size * sizeof(*dict->sorted) )))
{
heap_free( dict->dict.strings );
free( dict->dict.strings );
dict->dict.strings = NULL;
return E_OUTOFMEMORY;
}
if (!(dict->sequence = heap_alloc( new_size * sizeof(*dict->sequence) )))
if (!(dict->sequence = malloc( new_size * sizeof(*dict->sequence) )))
{
heap_free( dict->dict.strings );
free( dict->dict.strings );
dict->dict.strings = NULL;
heap_free( dict->sorted );
free( dict->sorted );
dict->sorted = NULL;
return E_OUTOFMEMORY;
}
......@@ -120,11 +120,11 @@ static HRESULT grow_dict( struct dictionary *dict, ULONG size )
}
new_size = max( dict->size * 2, size );
if (!(tmp = heap_realloc( dict->dict.strings, new_size * sizeof(*tmp) ))) return E_OUTOFMEMORY;
if (!(tmp = realloc( dict->dict.strings, new_size * sizeof(*tmp) ))) return E_OUTOFMEMORY;
dict->dict.strings = tmp;
if (!(tmp_sorted = heap_realloc( dict->sorted, new_size * sizeof(*tmp_sorted) ))) return E_OUTOFMEMORY;
if (!(tmp_sorted = realloc( dict->sorted, new_size * sizeof(*tmp_sorted) ))) return E_OUTOFMEMORY;
dict->sorted = tmp_sorted;
if (!(tmp_sequence = heap_realloc( dict->sequence, new_size * sizeof(*tmp_sequence) ))) return E_OUTOFMEMORY;
if (!(tmp_sequence = realloc( dict->sequence, new_size * sizeof(*tmp_sequence) ))) return E_OUTOFMEMORY;
dict->sequence = tmp_sequence;
dict->size = new_size;
......@@ -135,13 +135,13 @@ void clear_dict( struct dictionary *dict )
{
ULONG i;
assert( !dict->dict.isConst );
for (i = 0; i < dict->dict.stringCount; i++) heap_free( dict->dict.strings[i].bytes );
heap_free( dict->dict.strings );
for (i = 0; i < dict->dict.stringCount; i++) free( dict->dict.strings[i].bytes );
free( dict->dict.strings );
dict->dict.strings = NULL;
dict->dict.stringCount = 0;
heap_free( dict->sorted );
free( dict->sorted );
dict->sorted = NULL;
heap_free( dict->sequence );
free( dict->sequence );
dict->sequence = NULL;
dict->current_sequence = 0;
dict->size = 0;
......@@ -179,7 +179,7 @@ HRESULT add_xml_string( WS_XML_STRING *str )
EnterCriticalSection( &dict_cs );
if ((index = find_string( &dict_builtin, str->bytes, str->length, &id )) == -1)
{
heap_free( str->bytes );
free( str->bytes );
*str = dict_builtin.dict.strings[id];
}
else if ((hr = insert_string( &dict_builtin, str->bytes, str->length, index, &id )) == S_OK)
......@@ -194,10 +194,10 @@ WS_XML_STRING *alloc_xml_string( const unsigned char *data, ULONG len )
{
WS_XML_STRING *ret;
if (!(ret = heap_alloc_zero( sizeof(*ret) ))) return NULL;
if ((ret->length = len) && !(ret->bytes = heap_alloc( len )))
if (!(ret = calloc( 1, sizeof(*ret) ))) return NULL;
if ((ret->length = len) && !(ret->bytes = malloc( len )))
{
heap_free( ret );
free( ret );
return NULL;
}
if (data)
......@@ -211,8 +211,8 @@ WS_XML_STRING *alloc_xml_string( const unsigned char *data, ULONG len )
void free_xml_string( WS_XML_STRING *str )
{
if (!str) return;
if (!str->dictionary) heap_free( str->bytes );
heap_free( str );
if (!str->dictionary) free( str->bytes );
free( str );
}
WS_XML_STRING *dup_xml_string( const WS_XML_STRING *src, BOOL use_static_dict )
......@@ -223,7 +223,7 @@ WS_XML_STRING *dup_xml_string( const WS_XML_STRING *src, BOOL use_static_dict )
int index;
ULONG id;
if (!(ret = heap_alloc( sizeof(*ret) ))) return NULL;
if (!(ret = malloc( sizeof(*ret) ))) return NULL;
if (src->dictionary)
{
*ret = *src;
......@@ -241,9 +241,9 @@ WS_XML_STRING *dup_xml_string( const WS_XML_STRING *src, BOOL use_static_dict )
LeaveCriticalSection( &dict_cs );
return ret;
}
if (!(data = heap_alloc( src->length )))
if (!(data = malloc( src->length )))
{
heap_free( ret );
free( ret );
LeaveCriticalSection( &dict_cs );
return NULL;
}
......
......@@ -901,7 +901,7 @@ static void test_simple_struct_type(void)
s.fields = fields;
s.fieldCount = 1;
test = HeapAlloc( GetProcessHeap(), 0, sizeof(*test) );
test = malloc( sizeof(*test) );
test->field = L"value";
hr = WsWriteType( writer, WS_ELEMENT_CONTENT_TYPE_MAPPING, WS_STRUCT_TYPE, NULL,
WS_WRITE_REQUIRED_POINTER, &test, sizeof(test), NULL );
......@@ -968,7 +968,7 @@ static void test_simple_struct_type(void)
ok( hr == S_OK, "got %08x\n", hr );
check_output( writer, "<struct struct=\"value\"/>", __LINE__ );
HeapFree( GetProcessHeap(), 0, test );
free( test );
WsFreeWriter( writer );
}
......@@ -1005,7 +1005,7 @@ static void test_WsWriteElement(void)
desc.type = WS_STRUCT_TYPE;
desc.typeDescription = &s;
test = HeapAlloc( GetProcessHeap(), 0, sizeof(*test) );
test = malloc( sizeof(*test) );
test->str = L"test";
hr = WsWriteElement( NULL, &desc, WS_WRITE_REQUIRED_POINTER, &test, sizeof(test), NULL );
ok( hr == E_INVALIDARG, "got %08x\n", hr );
......@@ -1049,7 +1049,7 @@ static void test_WsWriteElement(void)
ok( hr == S_OK, "got %08x\n", hr );
check_output( writer, "<str str=\"test\"/>", __LINE__ );
HeapFree( GetProcessHeap(), 0, test );
free( test );
WsFreeWriter( writer );
}
......@@ -1192,7 +1192,7 @@ static void test_WsWriteAttribute(void)
desc.type = WS_STRUCT_TYPE;
desc.typeDescription = &s;
test = HeapAlloc( GetProcessHeap(), 0, sizeof(*test) );
test = malloc( sizeof(*test) );
test->str = L"test";
hr = WsWriteAttribute( NULL, &desc, WS_WRITE_REQUIRED_POINTER, &test, sizeof(test), NULL );
ok( hr == E_INVALIDARG, "got %08x\n", hr );
......@@ -1219,7 +1219,7 @@ static void test_WsWriteAttribute(void)
ok( hr == S_OK, "got %08x\n", hr );
check_output( writer, "<str str=\"test\"/>", __LINE__ );
HeapFree( GetProcessHeap(), 0, test );
free( test );
WsFreeWriter( writer );
}
......@@ -1652,7 +1652,7 @@ static void test_complex_struct_type(void)
s.typeNs = &ns;
size = sizeof(struct officeconfig) + sizeof(struct services);
test = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, size );
test = calloc( 1, size );
test->services = (struct services *)(test + 1);
test->services->generationtime = L"2015-09-03T18:47:54";
hr = WsWriteType( writer, WS_ELEMENT_CONTENT_TYPE_MAPPING, WS_STRUCT_TYPE, &s,
......@@ -1663,7 +1663,7 @@ static void test_complex_struct_type(void)
ok( hr == S_OK, "got %08x\n", hr );
check_output_buffer( buffer, expected, __LINE__ );
HeapFree( GetProcessHeap(), 0, test );
free( test );
WsFreeWriter( writer );
WsFreeHeap( heap );
}
......@@ -3116,7 +3116,7 @@ static void test_repeating_element(void)
hr = WsWriteStartElement( writer, NULL, &localname, &ns, NULL );
ok( hr == S_OK, "got %08x\n", hr );
test = HeapAlloc( GetProcessHeap(), 0, sizeof(*test) + 2 * sizeof(const WCHAR *) );
test = malloc( sizeof(*test) + 2 * sizeof(const WCHAR *) );
test->val = (const WCHAR **)(test + 1);
test->val[0] = L"1";
test->val[1] = L"2";
......@@ -3127,7 +3127,7 @@ static void test_repeating_element(void)
hr = WsWriteEndElement( writer, NULL );
ok( hr == S_OK, "got %08x\n", hr );
check_output( writer, "<test><wrapper><val>1</val><val>2</val></wrapper></test>", __LINE__ );
HeapFree( GetProcessHeap(), 0, test );
free( test );
/* array of integers, no wrapper */
hr = set_output( writer );
......@@ -3139,7 +3139,7 @@ static void test_repeating_element(void)
f.localName = NULL;
f.ns = NULL;
test2 = HeapAlloc( GetProcessHeap(), 0, sizeof(*test2) + 2 * sizeof(INT32) );
test2 = malloc( sizeof(*test2) + 2 * sizeof(INT32) );
test2->val = (INT32 *)(test2 + 1);
test2->val[0] = 1;
test2->val[1] = 2;
......@@ -3167,7 +3167,7 @@ static void test_repeating_element(void)
hr = WsWriteEndElement( writer, NULL );
ok( hr == S_OK, "got %08x\n", hr );
check_output( writer, "<test><val>1</val><val>2</val></test>", __LINE__ );
HeapFree( GetProcessHeap(), 0, test2 );
free( test2 );
/* nillable item */
hr = set_output( writer );
......@@ -3198,7 +3198,7 @@ static void test_repeating_element(void)
f.options = WS_FIELD_POINTER|WS_FIELD_OPTIONAL|WS_FIELD_NILLABLE|WS_FIELD_NILLABLE_ITEM;
value.data = -1;
test3 = HeapAlloc( GetProcessHeap(), 0, sizeof(*test3) + 2 * sizeof(const struct value *) );
test3 = malloc( sizeof(*test3) + 2 * sizeof(const struct value *) );
test3->val = (const struct value **)(test3 + 1);
test3->val[0] = &value;
test3->val[1] = NULL;
......@@ -3211,7 +3211,7 @@ static void test_repeating_element(void)
ok( hr == S_OK, "got %08x\n", hr );
check_output( writer, "<test><wrapper><val><data>-1</data></val><val a:nil=\"true\" "
"xmlns:a=\"http://www.w3.org/2001/XMLSchema-instance\"/></wrapper></test>", __LINE__ );
HeapFree( GetProcessHeap(), 0, test3 );
free( test3 );
WsFreeWriter( writer );
}
......
......@@ -17,6 +17,7 @@
*/
#include <stdarg.h>
#include <stdlib.h>
#include "windef.h"
#include "winbase.h"
......@@ -25,7 +26,6 @@
#include "webservices.h"
#include "wine/debug.h"
#include "wine/heap.h"
#include "wine/list.h"
#include "webservices_private.h"
......@@ -70,7 +70,7 @@ static unsigned char *strdup_utf8( const WCHAR *str, ULONG len, ULONG *ret_len )
{
unsigned char *ret;
*ret_len = WideCharToMultiByte( CP_UTF8, 0, str, len, NULL, 0, NULL, NULL );
if ((ret = heap_alloc( *ret_len )))
if ((ret = malloc( *ret_len )))
WideCharToMultiByte( CP_UTF8, 0, str, len, (char *)ret, *ret_len, NULL, NULL );
return ret;
}
......@@ -156,13 +156,13 @@ static WCHAR *url_decode( WCHAR *str, ULONG len, WS_HEAP *heap, ULONG *ret_len )
len_utf8, NULL, 0 )))
{
WARN( "invalid UTF-8 sequence\n" );
heap_free( utf8 );
free( utf8 );
return NULL;
}
if ((ret = ws_alloc( heap, *ret_len * sizeof(WCHAR) )))
MultiByteToWideChar( CP_UTF8, 0, (char *)utf8, len_utf8, ret, *ret_len );
heap_free( utf8 );
free( utf8 );
return ret;
}
......@@ -357,7 +357,7 @@ static HRESULT url_encode_size( const WCHAR *str, ULONG len, const char *except,
*ret_len = 0;
if (!(utf8 = strdup_utf8( str, len, &len_utf8 ))) return E_OUTOFMEMORY;
for (i = 0; i < len_utf8; i++) *ret_len += escape_size( utf8[i], except );
heap_free( utf8 );
free( utf8 );
return S_OK;
}
......@@ -416,7 +416,7 @@ static HRESULT url_encode( const WCHAR *str, ULONG len, WCHAR *buf, const char *
p += len_enc;
}
heap_free( utf8 );
free( utf8 );
return hr;
}
......
......@@ -18,6 +18,7 @@
#include <assert.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <float.h>
#include <math.h>
......@@ -29,7 +30,6 @@
#include "webservices.h"
#include "wine/debug.h"
#include "wine/heap.h"
#include "wine/list.h"
#include "webservices_private.h"
......@@ -106,7 +106,7 @@ static struct writer *alloc_writer(void)
struct writer *ret;
ULONG size = sizeof(*ret) + prop_size( writer_props, count );
if (!(ret = heap_alloc_zero( size ))) return NULL;
if (!(ret = calloc( 1, size ))) return NULL;
ret->magic = WRITER_MAGIC;
InitializeCriticalSection( &ret->cs );
......@@ -122,11 +122,11 @@ static void free_writer( struct writer *writer )
destroy_nodes( writer->root );
free_xml_string( writer->current_ns );
WsFreeHeap( writer->output_heap );
heap_free( writer->stream_buf );
free( writer->stream_buf );
writer->cs.DebugInfo->Spare[0] = 0;
DeleteCriticalSection( &writer->cs );
heap_free( writer );
free( writer );
}
static void write_insert_eof( struct writer *writer, struct node *eof )
......@@ -430,7 +430,7 @@ HRESULT WINAPI WsSetOutput( WS_XML_WRITER *handle, const WS_XML_WRITER_ENCODING
case WS_XML_WRITER_OUTPUT_TYPE_STREAM:
{
const WS_XML_WRITER_STREAM_OUTPUT *stream = (const WS_XML_WRITER_STREAM_OUTPUT *)output;
if (!writer->stream_buf && !(writer->stream_buf = heap_alloc( STREAM_BUFSIZE )))
if (!writer->stream_buf && !(writer->stream_buf = malloc( STREAM_BUFSIZE )))
{
hr = E_OUTOFMEMORY;
goto done;
......@@ -1283,12 +1283,12 @@ static HRESULT write_attribute_value_bin( struct writer *writer, const WS_XML_TE
len = text_utf8->value.length;
if ((hr = write_grow_buffer( writer, sizeof(len) + len )) != S_OK)
{
heap_free( new );
free( new );
return hr;
}
write_char( writer, len );
write_bytes( writer, text_utf8->value.bytes, len );
heap_free( new );
free( new );
return S_OK;
}
case RECORD_CHARS16_TEXT:
......@@ -1306,12 +1306,12 @@ static HRESULT write_attribute_value_bin( struct writer *writer, const WS_XML_TE
len = text_utf8->value.length;
if ((hr = write_grow_buffer( writer, sizeof(len) + len )) != S_OK)
{
heap_free( new );
free( new );
return hr;
}
write_bytes( writer, (const BYTE *)&len, sizeof(len) );
write_bytes( writer, text_utf8->value.bytes, len );
heap_free( new );
free( new );
return S_OK;
}
case RECORD_BYTES8_TEXT:
......@@ -1629,7 +1629,7 @@ static HRESULT add_namespace_attribute( struct writer *writer, const WS_XML_STRI
WS_XML_ELEMENT_NODE *elem = &writer->current->hdr;
HRESULT hr;
if (!(attr = heap_alloc_zero( sizeof(*attr) ))) return E_OUTOFMEMORY;
if (!(attr = calloc( 1, sizeof(*attr) ))) return E_OUTOFMEMORY;
attr->singleQuote = !!single;
attr->isXmlNs = 1;
......@@ -2044,7 +2044,7 @@ static HRESULT write_add_attribute( struct writer *writer, const WS_XML_STRING *
WS_XML_ELEMENT_NODE *elem = &writer->current->hdr;
HRESULT hr;
if (!(attr = heap_alloc_zero( sizeof(*attr) ))) return E_OUTOFMEMORY;
if (!(attr = calloc( 1, sizeof(*attr) ))) return E_OUTOFMEMORY;
if (!prefix && ns->length) prefix = elem->prefix;
......@@ -2477,7 +2477,7 @@ static HRESULT write_set_attribute_value( struct writer *writer, const WS_XML_TE
{
WS_XML_UTF8_TEXT *new, *old = (WS_XML_UTF8_TEXT *)elem->attributes[elem->attributeCount - 1]->value;
if ((hr = text_to_utf8text( value, old, NULL, &new )) != S_OK) return hr;
heap_free( old );
free( old );
elem->attributes[elem->attributeCount - 1]->value = &new->text;
break;
}
......@@ -2485,7 +2485,7 @@ static HRESULT write_set_attribute_value( struct writer *writer, const WS_XML_TE
{
WS_XML_TEXT *new, *old = elem->attributes[elem->attributeCount - 1]->value;
if ((hr = text_to_text( value, old, NULL, &new )) != S_OK) return hr;
heap_free( old );
free( old );
elem->attributes[elem->attributeCount - 1]->value = new;
break;
}
......@@ -2517,7 +2517,7 @@ static HRESULT write_add_text_node( struct writer *writer, const WS_XML_TEXT *va
WS_XML_UTF8_TEXT *new;
if ((hr = text_to_utf8text( value, NULL, NULL, &new )) != S_OK)
{
heap_free( node );
free( node );
return hr;
}
text->text = &new->text;
......@@ -2528,7 +2528,7 @@ static HRESULT write_add_text_node( struct writer *writer, const WS_XML_TEXT *va
WS_XML_TEXT *new;
if ((hr = text_to_text( value, NULL, NULL, &new )) != S_OK)
{
heap_free( node );
free( node );
return hr;
}
text->text = new;
......@@ -2536,7 +2536,7 @@ static HRESULT write_add_text_node( struct writer *writer, const WS_XML_TEXT *va
}
default:
FIXME( "unhandled output encoding %u\n", writer->output_enc );
heap_free( node );
free( node );
return E_NOTIMPL;
}
......@@ -2691,13 +2691,13 @@ static HRESULT write_text_bin( struct writer *writer, const WS_XML_TEXT *text, U
len = text_utf8->value.length;
if ((hr = write_grow_buffer( writer, 1 + sizeof(len) + len )) != S_OK)
{
heap_free( new );
free( new );
return hr;
}
write_char( writer, type );
write_char( writer, len );
write_bytes( writer, text_utf8->value.bytes, len );
heap_free( new );
free( new );
return S_OK;
}
case RECORD_CHARS16_TEXT_WITH_ENDELEMENT:
......@@ -2715,13 +2715,13 @@ static HRESULT write_text_bin( struct writer *writer, const WS_XML_TEXT *text, U
len = text_utf8->value.length;
if ((hr = write_grow_buffer( writer, 1 + sizeof(len) + len )) != S_OK)
{
heap_free( new );
free( new );
return hr;
}
write_char( writer, type );
write_bytes( writer, (const BYTE *)&len, sizeof(len) );
write_bytes( writer, text_utf8->value.bytes, len );
heap_free( new );
free( new );
return S_OK;
}
case RECORD_BYTES8_TEXT:
......@@ -2920,7 +2920,7 @@ static HRESULT write_text_node( struct writer *writer, const WS_XML_TEXT *text )
WS_XML_UTF8_TEXT *new, *old = (WS_XML_UTF8_TEXT *)node->text;
offset = old->value.length;
if ((hr = text_to_utf8text( text, old, &offset, &new )) != S_OK) return hr;
heap_free( old );
free( old );
node->text = &new->text;
break;
}
......@@ -2928,7 +2928,7 @@ static HRESULT write_text_node( struct writer *writer, const WS_XML_TEXT *text )
{
WS_XML_TEXT *new, *old = node->text;
if ((hr = text_to_text( text, old, &offset, &new )) != S_OK) return hr;
heap_free( old );
free( old );
node->text = new;
break;
}
......@@ -4610,7 +4610,7 @@ static HRESULT write_add_comment_node( struct writer *writer, const WS_XML_STRIN
if (!(node = alloc_node( WS_XML_NODE_TYPE_COMMENT ))) return E_OUTOFMEMORY;
comment = (WS_XML_COMMENT_NODE *)node;
if (value->length && !(comment->value.bytes = heap_alloc( value->length )))
if (value->length && !(comment->value.bytes = malloc( value->length )))
{
free_node( node );
return E_OUTOFMEMORY;
......
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