Commit 64d18bc1 authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

rpcrt4/tests: COM cleanup in cstub.c.

parent 2cd225b7
...@@ -691,10 +691,15 @@ static IUnknownVtbl create_stub_test_fail_vtbl = ...@@ -691,10 +691,15 @@ static IUnknownVtbl create_stub_test_fail_vtbl =
struct dummy_unknown struct dummy_unknown
{ {
const IUnknownVtbl *vtbl; IUnknown IUnknown_iface;
LONG ref; 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) static HRESULT WINAPI dummy_QueryInterface(IUnknown *This, REFIID iid, void **ppv)
{ {
*ppv = NULL; *ppv = NULL;
...@@ -703,13 +708,13 @@ static HRESULT WINAPI dummy_QueryInterface(IUnknown *This, REFIID iid, void **pp ...@@ -703,13 +708,13 @@ static HRESULT WINAPI dummy_QueryInterface(IUnknown *This, REFIID iid, void **pp
static ULONG WINAPI dummy_AddRef(LPUNKNOWN iface) 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 ); return InterlockedIncrement( &this->ref );
} }
static ULONG WINAPI dummy_Release(LPUNKNOWN iface) 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 ); return InterlockedDecrement( &this->ref );
} }
...@@ -719,7 +724,7 @@ static IUnknownVtbl dummy_unknown_vtbl = ...@@ -719,7 +724,7 @@ static IUnknownVtbl dummy_unknown_vtbl =
dummy_AddRef, dummy_AddRef,
dummy_Release 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 ) 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 ...@@ -737,7 +742,8 @@ static void create_proxy_test( IPSFactoryBuffer *ppsf, REFIID iid, const void *e
ok( count == 0, "wrong refcount %u\n", count ); ok( count == 0, "wrong refcount %u\n", count );
dummy_unknown.ref = 4; 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( r == S_OK, "IPSFactoryBuffer_CreateProxy failed %x\n", r );
ok( dummy_unknown.ref == 5, "wrong refcount %u\n", dummy_unknown.ref ); 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 ); ok( *(void **)iface == expected_vtbl, "wrong iface pointer %p/%p\n", *(void **)iface, expected_vtbl );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment