rpcrt4/tests: COM cleanup in cstub.c.

Michael Stefaniuc mstefani at redhat.de
Tue Mar 15 05:35:17 CDT 2011


---
 dlls/rpcrt4/tests/cstub.c |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/dlls/rpcrt4/tests/cstub.c b/dlls/rpcrt4/tests/cstub.c
index 7517a6d..7882e20 100644
--- a/dlls/rpcrt4/tests/cstub.c
+++ b/dlls/rpcrt4/tests/cstub.c
@@ -691,10 +691,15 @@ static IUnknownVtbl create_stub_test_fail_vtbl =
 
 struct dummy_unknown
 {
-    const IUnknownVtbl *vtbl;
+    IUnknown IUnknown_iface;
     LONG ref;
 };
 
+static inline struct dummy_unknown *impl_from_IUnknown(IUnknown *iface)
+{
+    return CONTAINING_RECORD(iface, struct dummy_unknown, IUnknown_iface);
+}
+
 static HRESULT WINAPI dummy_QueryInterface(IUnknown *This, REFIID iid, void **ppv)
 {
     *ppv = NULL;
@@ -703,13 +708,13 @@ static HRESULT WINAPI dummy_QueryInterface(IUnknown *This, REFIID iid, void **pp
 
 static ULONG WINAPI dummy_AddRef(LPUNKNOWN iface)
 {
-    struct dummy_unknown *this = (struct dummy_unknown *)iface;
+    struct dummy_unknown *this = impl_from_IUnknown(iface);
     return InterlockedIncrement( &this->ref );
 }
 
 static ULONG WINAPI dummy_Release(LPUNKNOWN iface)
 {
-    struct dummy_unknown *this = (struct dummy_unknown *)iface;
+    struct dummy_unknown *this = impl_from_IUnknown(iface);
     return InterlockedDecrement( &this->ref );
 }
 
@@ -719,7 +724,7 @@ static IUnknownVtbl dummy_unknown_vtbl =
     dummy_AddRef,
     dummy_Release
 };
-static struct dummy_unknown dummy_unknown = { &dummy_unknown_vtbl, 0 };
+static struct dummy_unknown dummy_unknown = { { &dummy_unknown_vtbl }, 0 };
 
 static void create_proxy_test( IPSFactoryBuffer *ppsf, REFIID iid, const void *expected_vtbl )
 {
@@ -737,7 +742,8 @@ static void create_proxy_test( IPSFactoryBuffer *ppsf, REFIID iid, const void *e
     ok( count == 0, "wrong refcount %u\n", count );
 
     dummy_unknown.ref = 4;
-    r = IPSFactoryBuffer_CreateProxy(ppsf, (IUnknown *)&dummy_unknown, iid, &proxy, (void **)&iface);
+    r = IPSFactoryBuffer_CreateProxy(ppsf, &dummy_unknown.IUnknown_iface, iid, &proxy,
+            (void **)&iface);
     ok( r == S_OK, "IPSFactoryBuffer_CreateProxy failed %x\n", r );
     ok( dummy_unknown.ref == 5, "wrong refcount %u\n", dummy_unknown.ref );
     ok( *(void **)iface == expected_vtbl, "wrong iface pointer %p/%p\n", *(void **)iface, expected_vtbl );
-- 
1.7.4



More information about the wine-patches mailing list