From 1fd704b3af6de6a3c2ac0a5576689290e3832a7a Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Fri, 10 Jan 2014 10:27:59 +1100 Subject: [PATCH] dpnet: Cleanup IDirectPlay8Peer COM interface. --- dlls/dpnet/dpnet_private.h | 10 ---------- dlls/dpnet/peer.c | 24 +++++++++++++++++++----- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/dlls/dpnet/dpnet_private.h b/dlls/dpnet/dpnet_private.h index 72012cd528c..4a42eaec8e6 100644 --- a/dlls/dpnet/dpnet_private.h +++ b/dlls/dpnet/dpnet_private.h @@ -35,7 +35,6 @@ typedef struct IDirectPlay8ClientImpl IDirectPlay8ClientImpl; typedef struct IDirectPlay8AddressImpl IDirectPlay8AddressImpl; typedef struct IDirectPlay8LobbiedApplicationImpl IDirectPlay8LobbiedApplicationImpl; -typedef struct IDirectPlay8PeerImpl IDirectPlay8PeerImpl; typedef struct IDirectPlay8ThreadPoolImpl IDirectPlay8ThreadPoolImpl; /* ------------------ */ @@ -77,15 +76,6 @@ struct IDirectPlay8LobbiedApplicationImpl LONG ref; }; -/***************************************************************************** - * IDirectPlay8Peer implementation structure - */ -struct IDirectPlay8PeerImpl -{ - IDirectPlay8Peer IDirectPlay8Peer_iface; - LONG ref; -}; - /***************************************************************************** * IDirectPlay8ThreadPool implementation structure */ diff --git a/dlls/dpnet/peer.c b/dlls/dpnet/peer.c index ef100a30f63..1b287ddd57d 100644 --- a/dlls/dpnet/peer.c +++ b/dlls/dpnet/peer.c @@ -38,6 +38,13 @@ WINE_DEFAULT_DEBUG_CHANNEL(dpnet); + +typedef struct IDirectPlay8PeerImpl +{ + IDirectPlay8Peer IDirectPlay8Peer_iface; + LONG ref; +} IDirectPlay8PeerImpl; + static inline IDirectPlay8PeerImpl *impl_from_IDirectPlay8Peer(IDirectPlay8Peer *iface) { return CONTAINING_RECORD(iface, IDirectPlay8PeerImpl, IDirectPlay8Peer_iface); @@ -66,6 +73,8 @@ static ULONG WINAPI IDirectPlay8PeerImpl_AddRef(IDirectPlay8Peer *iface) IDirectPlay8PeerImpl* This = impl_from_IDirectPlay8Peer(iface); ULONG RefCount = InterlockedIncrement(&This->ref); + TRACE("(%p) ref=%d\n", This, RefCount); + return RefCount; } @@ -74,6 +83,8 @@ static ULONG WINAPI IDirectPlay8PeerImpl_Release(IDirectPlay8Peer *iface) IDirectPlay8PeerImpl* This = impl_from_IDirectPlay8Peer(iface); ULONG RefCount = InterlockedDecrement(&This->ref); + TRACE("(%p) ref=%d\n", This, RefCount); + if(!RefCount) HeapFree(GetProcessHeap(), 0, This); @@ -474,23 +485,26 @@ static const IDirectPlay8PeerVtbl DirectPlay8Peer_Vtbl = IDirectPlay8PeerImpl_TerminateSession }; -HRESULT DPNET_CreateDirectPlay8Peer(LPCLASSFACTORY iface, LPUNKNOWN punkOuter, REFIID riid, LPVOID *ppobj) { +HRESULT DPNET_CreateDirectPlay8Peer(IClassFactory *iface, IUnknown *pUnkOuter, REFIID riid, LPVOID *ppobj) +{ IDirectPlay8PeerImpl* Client; HRESULT ret; Client = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectPlay8PeerImpl)); + *ppobj = NULL; + if(Client == NULL) { - *ppobj = NULL; WARN("Not enough memory\n"); return E_OUTOFMEMORY; } Client->IDirectPlay8Peer_iface.lpVtbl = &DirectPlay8Peer_Vtbl; - ret = IDirectPlay8PeerImpl_QueryInterface(&Client->IDirectPlay8Peer_iface, riid, ppobj); - if(ret != DPN_OK) - HeapFree(GetProcessHeap(), 0, Client); + Client->ref = 1; + + ret = IDirectPlay8Peer_QueryInterface(&Client->IDirectPlay8Peer_iface, riid, ppobj); + IDirectPlay8Peer_Release(&Client->IDirectPlay8Peer_iface); return ret; }