rpcrt4/tests: COM cleanup in cstub.c.

This commit is contained in:
Michael Stefaniuc 2011-03-15 11:35:17 +01:00 committed by Alexandre Julliard
parent 2cd225b793
commit 64d18bc1f0
1 changed files with 11 additions and 5 deletions

View File

@ -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 );