diff --git a/dlls/webservices/reader.c b/dlls/webservices/reader.c index 48b9c01a688..96a3dc3ffff 100644 --- a/dlls/webservices/reader.c +++ b/dlls/webservices/reader.c @@ -170,6 +170,23 @@ void ws_free( WS_HEAP *handle, void *ptr ) HeapFree( heap->handle, 0, ptr ); } +/************************************************************************** + * WsAlloc [webservices.@] + */ +HRESULT WINAPI WsAlloc( WS_HEAP *handle, SIZE_T size, void **ptr, WS_ERROR *error ) +{ + void *mem; + + TRACE( "%p %u %p %p\n", handle, (ULONG)size, ptr, error ); + if (error) FIXME( "ignoring error parameter\n" ); + + if (!handle || !ptr) return E_INVALIDARG; + + if (!(mem = ws_alloc( handle, size ))) return E_OUTOFMEMORY; + *ptr = mem; + return S_OK; +} + static struct heap *alloc_heap(void) { static const ULONG count = sizeof(heap_props)/sizeof(heap_props[0]); diff --git a/dlls/webservices/tests/reader.c b/dlls/webservices/tests/reader.c index 1f9558cbf36..dab57f10cd6 100644 --- a/dlls/webservices/tests/reader.c +++ b/dlls/webservices/tests/reader.c @@ -1453,6 +1453,32 @@ static void test_WsXmlStringEquals(void) ok( hr == S_OK, "got %08x\n", hr ); } +static void test_WsAlloc(void) +{ + HRESULT hr; + WS_HEAP *heap; + void *ptr; + + hr = WsCreateHeap( 256, 0, NULL, 0, &heap, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + + ptr = NULL; + hr = WsAlloc( NULL, 16, &ptr, NULL ); + ok( hr == E_INVALIDARG, "got %08x\n", hr ); + ok( ptr == NULL, "ptr set\n" ); + + ptr = NULL; + hr = WsAlloc( heap, 512, &ptr, NULL ); + todo_wine ok( hr == WS_E_QUOTA_EXCEEDED, "got %08x\n", hr ); + todo_wine ok( ptr == NULL, "ptr not set\n" ); + + ptr = NULL; + hr = WsAlloc( heap, 16, &ptr, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + ok( ptr != NULL, "ptr not set\n" ); + WsFreeHeap( heap ); +} + START_TEST(reader) { test_WsCreateError(); @@ -1468,4 +1494,5 @@ START_TEST(reader) test_WsReadType(); test_WsGetXmlAttribute(); test_WsXmlStringEquals(); + test_WsAlloc(); } diff --git a/dlls/webservices/webservices.spec b/dlls/webservices/webservices.spec index 3378ea9f6b4..1f0bfdc72c2 100644 --- a/dlls/webservices/webservices.spec +++ b/dlls/webservices/webservices.spec @@ -9,7 +9,7 @@ @ stub WsAddErrorString @ stub WsAddMappedHeader @ stub WsAddressMessage -@ stub WsAlloc +@ stdcall WsAlloc(ptr long ptr ptr) @ stub WsAsyncExecute @ stub WsCall @ stub WsCheckMustUnderstandHeaders diff --git a/include/webservices.h b/include/webservices.h index 0ebb6c48caf..594a6ba677b 100644 --- a/include/webservices.h +++ b/include/webservices.h @@ -464,6 +464,7 @@ typedef struct _WS_XML_NODE_POSITION { void *node; } WS_XML_NODE_POSITION; +HRESULT WINAPI WsAlloc(WS_HEAP*, SIZE_T, void**, WS_ERROR*); HRESULT WINAPI WsCreateError(const WS_ERROR_PROPERTY*, ULONG, WS_ERROR**); HRESULT WINAPI WsCreateHeap(SIZE_T, SIZE_T, const WS_HEAP_PROPERTY*, ULONG, WS_HEAP**, WS_ERROR*); HRESULT WINAPI WsCreateReader(const WS_XML_READER_PROPERTY*, ULONG, WS_XML_READER**, WS_ERROR*);