Module: wine Branch: master Commit: 64d18bc1f0fce5f9baa97cba96a828f221a88c69 URL: http://source.winehq.org/git/wine.git/?a=commit;h=64d18bc1f0fce5f9baa97cba96...
Author: Michael Stefaniuc mstefani@redhat.de Date: Tue Mar 15 11:35:17 2011 +0100
rpcrt4/tests: COM cleanup in cstub.c.
---
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 );