From: Alistair Leslie-Hughes leslie_alistair@hotmail.com
--- dlls/dplayx/dplobby.c | 27 ++++++++++++--------------- dlls/dplayx/tests/dplayx.c | 23 +---------------------- 2 files changed, 13 insertions(+), 37 deletions(-)
diff --git a/dlls/dplayx/dplobby.c b/dlls/dplayx/dplobby.c index 4dbed849259..283096a530e 100644 --- a/dlls/dplayx/dplobby.c +++ b/dlls/dplayx/dplobby.c @@ -68,7 +68,7 @@ typedef struct IDirectPlayLobbyImpl IDirectPlayLobby3 IDirectPlayLobby3_iface; IDirectPlayLobby3A IDirectPlayLobby3A_iface; LONG numIfaces; /* "in use interfaces" refcount */ - LONG ref, ref2, ref3, ref3A; + LONG ref; CRITICAL_SECTION lock; HKEY cbkeyhack; DWORD msgtid; @@ -186,7 +186,7 @@ static ULONG WINAPI IDirectPlayLobbyImpl_AddRef( IDirectPlayLobby *iface ) static ULONG WINAPI IDirectPlayLobby2Impl_AddRef(IDirectPlayLobby2 *iface) { IDirectPlayLobbyImpl *This = impl_from_IDirectPlayLobby2( iface ); - ULONG ref = InterlockedIncrement( &This->ref2 ); + ULONG ref = InterlockedIncrement( &This->ref );
TRACE( "(%p) ref2=%ld\n", This, ref );
@@ -199,9 +199,9 @@ static ULONG WINAPI IDirectPlayLobby2Impl_AddRef(IDirectPlayLobby2 *iface) static ULONG WINAPI IDirectPlayLobby3AImpl_AddRef(IDirectPlayLobby3A *iface) { IDirectPlayLobbyImpl *This = impl_from_IDirectPlayLobby3A( iface ); - ULONG ref = InterlockedIncrement( &This->ref3A ); + ULONG ref = InterlockedIncrement( &This->ref );
- TRACE( "(%p) ref3A=%ld\n", This, ref ); + TRACE( "(%p) ref3=%ld\n", This, ref );
if ( ref == 1 ) InterlockedIncrement( &This->numIfaces ); @@ -212,7 +212,7 @@ static ULONG WINAPI IDirectPlayLobby3AImpl_AddRef(IDirectPlayLobby3A *iface) static ULONG WINAPI IDirectPlayLobby3Impl_AddRef(IDirectPlayLobby3 *iface) { IDirectPlayLobbyImpl *This = impl_from_IDirectPlayLobby3( iface ); - ULONG ref = InterlockedIncrement( &This->ref3 ); + ULONG ref = InterlockedIncrement( &This->ref );
TRACE( "(%p) ref3=%ld\n", This, ref );
@@ -238,9 +238,9 @@ static ULONG WINAPI IDirectPlayLobbyImpl_Release( IDirectPlayLobby *iface ) static ULONG WINAPI IDirectPlayLobby2Impl_Release(IDirectPlayLobby2 *iface) { IDirectPlayLobbyImpl *This = impl_from_IDirectPlayLobby2( iface ); - ULONG ref = InterlockedDecrement( &This->ref2 ); + ULONG ref = InterlockedDecrement( &This->ref );
- TRACE( "(%p) ref2=%ld\n", This, ref ); + TRACE( "(%p) ref=%ld\n", This, ref );
if ( !ref && !InterlockedDecrement( &This->numIfaces ) ) dplobby_destroy( This ); @@ -251,9 +251,9 @@ static ULONG WINAPI IDirectPlayLobby2Impl_Release(IDirectPlayLobby2 *iface) static ULONG WINAPI IDirectPlayLobby3AImpl_Release(IDirectPlayLobby3A *iface) { IDirectPlayLobbyImpl *This = impl_from_IDirectPlayLobby3A( iface ); - ULONG ref = InterlockedDecrement( &This->ref3A ); + ULONG ref = InterlockedDecrement( &This->ref );
- TRACE( "(%p) ref3A=%ld\n", This, ref ); + TRACE( "(%p) ref=%ld\n", This, ref );
if ( !ref && !InterlockedDecrement( &This->numIfaces ) ) dplobby_destroy( This ); @@ -264,9 +264,9 @@ static ULONG WINAPI IDirectPlayLobby3AImpl_Release(IDirectPlayLobby3A *iface) static ULONG WINAPI IDirectPlayLobby3Impl_Release(IDirectPlayLobby3 *iface) { IDirectPlayLobbyImpl *This = impl_from_IDirectPlayLobby3( iface ); - ULONG ref = InterlockedDecrement( &This->ref3 ); + ULONG ref = InterlockedDecrement( &This->ref );
- TRACE( "(%p) ref3=%ld\n", This, ref ); + TRACE( "(%p) ref=%ld\n", This, ref );
if ( !ref && !InterlockedDecrement( &This->numIfaces ) ) dplobby_destroy( This ); @@ -1732,10 +1732,7 @@ HRESULT dplobby_create( REFIID riid, void **ppv ) obj->IDirectPlayLobby3A_iface.lpVtbl = &dpl3A_vt; obj->numIfaces = 1; obj->msgtid = 0; - obj->ref = 0; - obj->ref2 = 0; - obj->ref3 = 1; - obj->ref3A = 0; + obj->ref = 1;
InitializeCriticalSectionEx( &obj->lock, 0, RTL_CRITICAL_SECTION_FLAG_FORCE_DEBUG_INFO ); obj->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": IDirectPlayLobbyImpl.lock"); diff --git a/dlls/dplayx/tests/dplayx.c b/dlls/dplayx/tests/dplayx.c index e7c2d0b5258..e9ff1f6a673 100644 --- a/dlls/dplayx/tests/dplayx.c +++ b/dlls/dplayx/tests/dplayx.c @@ -6652,53 +6652,32 @@ static void test_COM_dplobby(void) hr = CoCreateInstance(&CLSID_DirectPlayLobby, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectPlayLobby, (void**)&dpl); ok(hr == S_OK, "DirectPlayLobby create failed: %08lx, expected S_OK\n", hr); - refcount = IDirectPlayLobby_AddRef(dpl); - ok(refcount == 2, "refcount == %lu, expected 2\n", refcount);
hr = IDirectPlayLobby_QueryInterface(dpl, &IID_IDirectPlayLobbyA, (void**)&dplA); ok(hr == S_OK, "QueryInterface for IID_IDirectPlayLobbyA failed: %08lx\n", hr); - refcount = IDirectPlayLobby_AddRef(dplA); - ok(refcount == 2, "refcount == %lu, expected 2\n", refcount); IDirectPlayLobby_Release(dplA);
hr = IDirectPlayLobby_QueryInterface(dpl, &IID_IDirectPlayLobby2, (void**)&dpl2); ok(hr == S_OK, "QueryInterface for IID_IDirectPlayLobby2 failed: %08lx\n", hr); - refcount = IDirectPlayLobby_AddRef(dpl2); - ok(refcount == 2, "refcount == %lu, expected 2\n", refcount); IDirectPlayLobby_Release(dpl2);
hr = IDirectPlayLobby_QueryInterface(dpl, &IID_IDirectPlayLobby2A, (void**)&dpl2A); ok(hr == S_OK, "QueryInterface for IID_IDirectPlayLobby2A failed: %08lx\n", hr); - refcount = IDirectPlayLobby_AddRef(dpl2A); - ok(refcount == 2, "refcount == %lu, expected 2\n", refcount); IDirectPlayLobby_Release(dpl2A);
hr = IDirectPlayLobby_QueryInterface(dpl, &IID_IDirectPlayLobby3, (void**)&dpl3); ok(hr == S_OK, "QueryInterface for IID_IDirectPlayLobby3 failed: %08lx\n", hr); - refcount = IDirectPlayLobby_AddRef(dpl3); - ok(refcount == 2, "refcount == %lu, expected 2\n", refcount); IDirectPlayLobby_Release(dpl3);
hr = IDirectPlayLobby_QueryInterface(dpl, &IID_IDirectPlayLobby3A, (void**)&dpl3A); ok(hr == S_OK, "QueryInterface for IID_IDirectPlayLobby3A failed: %08lx\n", hr); - refcount = IDirectPlayLobby_AddRef(dpl3A); - ok(refcount == 2, "refcount == %lu, expected 2\n", refcount); IDirectPlayLobby_Release(dpl3A);
/* IDirectPlayLobby and IUnknown share a refcount */ hr = IDirectPlayX_QueryInterface(dpl, &IID_IUnknown, (void**)&unk); ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08lx\n", hr); - refcount = IUnknown_AddRef(unk); - ok(refcount == 4, "refcount == %lu, expected 4\n", refcount); - IDirectPlayLobby_Release(unk); - IUnknown_Release(unk); - IDirectPlayLobby_Release(dpl3); - IDirectPlayLobby_Release(dpl3A); - IDirectPlayLobby_Release(dpl2); - IDirectPlayLobby_Release(dpl2A); - IDirectPlayLobby_Release(dplA); - IDirectPlayLobby_Release(dpl); + refcount = IDirectPlayLobby_Release(dpl); ok(refcount == 0, "refcount == %lu, expected 0\n", refcount); }