[1/2] dpnet: Cleanup IDirectPlay8Peer COM interface

Alistair Leslie-Hughes leslie_alistair at hotmail.com
Fri Jan 10 01:18:17 CST 2014


Hi,


Changelog:
     dpnet: Cleanup IDirectPlay8Peer COM interface


Best Regards
  Alistair Leslie-Hughes
-------------- next part --------------
>From bffc69aae361c90efa3d9d5ae89d05562ee22844 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date: Fri, 10 Jan 2014 10:27:59 +1100
Subject: [PATCH] Cleanup IDirectPlay8Peer COM interface
To: wine-patches <wine-patches at winehq.org>

---
 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 72012cd..4a42eae 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;
 
 /* ------------------ */
@@ -78,15 +77,6 @@ struct IDirectPlay8LobbiedApplicationImpl
 };
 
 /*****************************************************************************
- * IDirectPlay8Peer implementation structure
- */
-struct IDirectPlay8PeerImpl
-{
-  IDirectPlay8Peer IDirectPlay8Peer_iface;
-  LONG ref;
-};
-
-/*****************************************************************************
  * IDirectPlay8ThreadPool implementation structure
  */
 struct IDirectPlay8ThreadPoolImpl
diff --git a/dlls/dpnet/peer.c b/dlls/dpnet/peer.c
index ef100a3..1b287dd 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;
 }
-- 
1.8.3.2



More information about the wine-patches mailing list