Hans Leidekker : webservices: Implement WsCreateHeap and WsFreeHeap.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Sep 14 09:44:35 CDT 2015


Module: wine
Branch: master
Commit: 5db34f7da17fdd86fc797b3bbea8401fb51041db
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=5db34f7da17fdd86fc797b3bbea8401fb51041db

Author: Hans Leidekker <hans at codeweavers.com>
Date:   Mon Sep 14 14:04:01 2015 +0200

webservices: Implement WsCreateHeap and WsFreeHeap.

---

 dlls/webservices/reader.c         | 91 +++++++++++++++++++++++++++++++++++++++
 dlls/webservices/webservices.spec |  4 +-
 2 files changed, 93 insertions(+), 2 deletions(-)

diff --git a/dlls/webservices/reader.c b/dlls/webservices/reader.c
index ac7de65..3084fe5 100644
--- a/dlls/webservices/reader.c
+++ b/dlls/webservices/reader.c
@@ -150,6 +150,97 @@ void WINAPI WsFreeError( WS_ERROR *handle )
     heap_free( error );
 }
 
+static const struct
+{
+    ULONG size;
+    BOOL  readonly;
+}
+heap_props[] =
+{
+    { sizeof(SIZE_T), FALSE }, /* WS_HEAP_PROPERTY_MAX_SIZE */
+    { sizeof(SIZE_T), FALSE }, /* WS_HEAP_PROPERTY_TRIM_SIZE */
+    { sizeof(SIZE_T), TRUE },  /* WS_HEAP_PROPERTY_REQUESTED_SIZE */
+    { sizeof(SIZE_T), TRUE }   /* WS_HEAP_PROPERTY_ACTUAL_SIZE */
+};
+
+struct heap
+{
+    HANDLE           handle;
+    ULONG            prop_count;
+    WS_HEAP_PROPERTY prop[sizeof(heap_props)/sizeof(heap_props[0])];
+};
+
+static struct heap *alloc_heap(void)
+{
+    static const ULONG count = sizeof(heap_props)/sizeof(heap_props[0]);
+    struct heap *ret;
+    ULONG i, size = sizeof(*ret) + count * sizeof(WS_HEAP_PROPERTY);
+    char *ptr;
+
+    for (i = 0; i < count; i++) size += heap_props[i].size;
+    if (!(ret = heap_alloc_zero( size ))) return NULL;
+
+    ptr = (char *)&ret->prop[count];
+    for (i = 0; i < count; i++)
+    {
+        ret->prop[i].value = ptr;
+        ret->prop[i].valueSize = heap_props[i].size;
+        ptr += ret->prop[i].valueSize;
+    }
+    ret->prop_count = count;
+    return ret;
+}
+
+static HRESULT set_heap_prop( struct heap *heap, WS_HEAP_PROPERTY_ID id, const void *value, ULONG size )
+{
+    if (id >= heap->prop_count || size != heap_props[id].size || heap_props[id].readonly)
+        return E_INVALIDARG;
+
+    memcpy( heap->prop[id].value, value, size );
+    return S_OK;
+}
+
+/**************************************************************************
+ *          WsCreateHeap		[webservices.@]
+ */
+HRESULT WINAPI WsCreateHeap( SIZE_T max_size, SIZE_T trim_size, const WS_HEAP_PROPERTY *properties,
+                             ULONG count, WS_HEAP **handle, WS_ERROR *error )
+{
+    struct heap *heap;
+
+    TRACE( "%u %u %p %u %p %p\n", (ULONG)max_size, (ULONG)trim_size, properties, count, handle, error );
+    if (error) FIXME( "ignoring error parameter\n" );
+
+    if (!handle || count) return E_INVALIDARG;
+    if (!(heap = alloc_heap())) return E_OUTOFMEMORY;
+
+    set_heap_prop( heap, WS_HEAP_PROPERTY_MAX_SIZE, &max_size, sizeof(max_size) );
+    set_heap_prop( heap, WS_HEAP_PROPERTY_TRIM_SIZE, &trim_size, sizeof(trim_size) );
+
+    if (!(heap->handle = HeapCreate( 0, 0, max_size )))
+    {
+        heap_free( heap );
+        return E_OUTOFMEMORY;
+    }
+
+    *handle = (WS_HEAP *)heap;
+    return S_OK;
+}
+
+/**************************************************************************
+ *          WsFreeHeap		[webservices.@]
+ */
+void WINAPI WsFreeHeap( WS_HEAP *handle )
+{
+    struct heap *heap = (struct heap *)handle;
+
+    TRACE( "%p\n", handle );
+
+    if (!heap) return;
+    HeapDestroy( heap->handle );
+    heap_free( heap );
+}
+
 /**************************************************************************
  *          WsGetErrorProperty		[webservices.@]
  */
diff --git a/dlls/webservices/webservices.spec b/dlls/webservices/webservices.spec
index 0ff3c0d..4136dcc 100644
--- a/dlls/webservices/webservices.spec
+++ b/dlls/webservices/webservices.spec
@@ -24,7 +24,7 @@
 @ stub WsCreateChannelForListener
 @ stdcall WsCreateError(ptr long ptr)
 @ stub WsCreateFaultFromError
-@ stub WsCreateHeap
+@ stdcall WsCreateHeap(long long ptr long ptr ptr)
 @ stub WsCreateListener
 @ stub WsCreateMessage
 @ stub WsCreateMessageForChannel
@@ -50,7 +50,7 @@
 @ stub WsFlushWriter
 @ stub WsFreeChannel
 @ stdcall WsFreeError(ptr)
-@ stub WsFreeHeap
+@ stdcall WsFreeHeap(ptr)
 @ stub WsFreeListener
 @ stub WsFreeMessage
 @ stub WsFreeMetadata




More information about the wine-cvs mailing list