[5/8] webservices: Implement WsCreateXmlBuffer.

Hans Leidekker hans at codeweavers.com
Thu Oct 22 03:17:18 CDT 2015


Signed-off-by: Hans Leidekker <hans at codeweavers.com>
---
 dlls/webservices/reader.c              | 20 +++++++++++++-------
 dlls/webservices/webservices.spec      |  2 +-
 dlls/webservices/webservices_private.h | 11 +++++++++++
 dlls/webservices/writer.c              | 34 ++++++++++++++++++++++++++++++++++
 4 files changed, 59 insertions(+), 8 deletions(-)

diff --git a/dlls/webservices/reader.c b/dlls/webservices/reader.c
index 7ae4e34..870e7de 100644
--- a/dlls/webservices/reader.c
+++ b/dlls/webservices/reader.c
@@ -158,6 +158,18 @@ struct heap
     WS_HEAP_PROPERTY prop[sizeof(heap_props)/sizeof(heap_props[0])];
 };
 
+void *ws_alloc( WS_HEAP *handle, SIZE_T size )
+{
+    struct heap *heap = (struct heap *)handle;
+    return HeapAlloc( heap->handle, 0, size );
+}
+
+void ws_free( WS_HEAP *handle, void *ptr )
+{
+    struct heap *heap = (struct heap *)handle;
+    HeapFree( heap->handle, 0, ptr );
+}
+
 static struct heap *alloc_heap(void)
 {
     static const ULONG count = sizeof(heap_props)/sizeof(heap_props[0]);
@@ -1103,12 +1115,6 @@ HRESULT WINAPI WsReadToStartElement( WS_XML_READER *handle, const WS_XML_STRING
     return read_to_startelement( reader, found );
 }
 
-static void *read_alloc( WS_HEAP *handle, SIZE_T size )
-{
-    struct heap *heap = (struct heap *)handle;
-    return HeapAlloc( heap->handle, 0, size );
-}
-
 static WCHAR *xmltext_to_widechar( WS_HEAP *heap, const WS_XML_TEXT *text )
 {
     WCHAR *ret;
@@ -1119,7 +1125,7 @@ static WCHAR *xmltext_to_widechar( WS_HEAP *heap, const WS_XML_TEXT *text )
     {
         const WS_XML_UTF8_TEXT *utf8 = (const WS_XML_UTF8_TEXT *)text;
         int len = MultiByteToWideChar( CP_UTF8, 0, (char *)utf8->value.bytes, utf8->value.length, NULL, 0 );
-        if (!(ret = read_alloc( heap, (len + 1) * sizeof(WCHAR) ))) return NULL;
+        if (!(ret = ws_alloc( heap, (len + 1) * sizeof(WCHAR) ))) return NULL;
         MultiByteToWideChar( CP_UTF8, 0, (char *)utf8->value.bytes, utf8->value.length, ret, len );
         ret[len] = 0;
         break;
diff --git a/dlls/webservices/webservices.spec b/dlls/webservices/webservices.spec
index b666a08..c070d2f 100644
--- a/dlls/webservices/webservices.spec
+++ b/dlls/webservices/webservices.spec
@@ -35,7 +35,7 @@
 @ stub WsCreateServiceProxy
 @ stub WsCreateServiceProxyFromTemplate
 @ stdcall WsCreateWriter(ptr long ptr ptr)
-@ stub WsCreateXmlBuffer
+@ stdcall WsCreateXmlBuffer(ptr ptr long ptr ptr)
 @ stub WsCreateXmlSecurityToken
 @ stub WsDateTimeToFileTime
 @ stub WsDecodeUrl
diff --git a/dlls/webservices/webservices_private.h b/dlls/webservices/webservices_private.h
index 20d3f0b..369ccbb 100644
--- a/dlls/webservices/webservices_private.h
+++ b/dlls/webservices/webservices_private.h
@@ -16,6 +16,17 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
+struct xmlbuf
+{
+    WS_HEAP *heap;
+    void    *ptr;
+    SIZE_T   size_allocated;
+    SIZE_T   size;
+};
+
+void *ws_alloc( WS_HEAP *, SIZE_T ) DECLSPEC_HIDDEN;
+void ws_free( WS_HEAP *, void * ) DECLSPEC_HIDDEN;
+
 static inline void *heap_alloc( SIZE_T size )
 {
     return HeapAlloc( GetProcessHeap(), 0, size );
diff --git a/dlls/webservices/writer.c b/dlls/webservices/writer.c
index 620cc46..821b082 100644
--- a/dlls/webservices/writer.c
+++ b/dlls/webservices/writer.c
@@ -152,6 +152,40 @@ void WINAPI WsFreeWriter( WS_XML_WRITER *handle )
     heap_free( writer );
 }
 
+#define XML_BUFFER_INITIAL_ALLOCATED_SIZE 256
+static struct xmlbuf *alloc_xmlbuf( WS_HEAP *heap )
+{
+    struct xmlbuf *ret;
+
+    if (!(ret = ws_alloc( heap, sizeof(*ret) ))) return NULL;
+    if (!(ret->ptr = ws_alloc( heap, XML_BUFFER_INITIAL_ALLOCATED_SIZE )))
+    {
+        ws_free( heap, ret );
+        return NULL;
+    }
+    ret->heap           = heap;
+    ret->size_allocated = XML_BUFFER_INITIAL_ALLOCATED_SIZE;
+    ret->size           = 0;
+    return ret;
+}
+
+/**************************************************************************
+ *          WsCreateXmlBuffer		[webservices.@]
+ */
+HRESULT WINAPI WsCreateXmlBuffer( WS_HEAP *heap, const WS_XML_BUFFER_PROPERTY *properties,
+                                  ULONG count, WS_XML_BUFFER **handle, WS_ERROR *error )
+{
+    struct xmlbuf *xmlbuf;
+
+    if (!heap || !handle) return E_INVALIDARG;
+    if (count) FIXME( "properties not implemented\n" );
+
+    if (!(xmlbuf = alloc_xmlbuf( heap ))) return E_OUTOFMEMORY;
+
+    *handle = (WS_XML_BUFFER *)xmlbuf;
+    return S_OK;
+}
+
 /**************************************************************************
  *          WsGetWriterProperty		[webservices.@]
  */
-- 
2.6.1




More information about the wine-patches mailing list