Alistair Leslie-Hughes : dpnet: Cleanup IDirectPlay8Address.

Alexandre Julliard julliard at winehq.org
Wed Apr 30 13:32:51 CDT 2014


Module: wine
Branch: master
Commit: 91414e8ef8340a5afafb3418d6024c100e7dfb8e
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=91414e8ef8340a5afafb3418d6024c100e7dfb8e

Author: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date:   Fri Apr 11 09:55:59 2014 +1000

dpnet: Cleanup IDirectPlay8Address.

---

 dlls/dpnet/address.c |   45 ++++++++++++++++++++++++++-------------------
 1 file changed, 26 insertions(+), 19 deletions(-)

diff --git a/dlls/dpnet/address.c b/dlls/dpnet/address.c
index 796e8a4..9266fea 100644
--- a/dlls/dpnet/address.c
+++ b/dlls/dpnet/address.c
@@ -58,24 +58,24 @@ static HRESULT WINAPI IDirectPlay8AddressImpl_QueryInterface(IDirectPlay8Address
 static ULONG WINAPI IDirectPlay8AddressImpl_AddRef(IDirectPlay8Address *iface)
 {
     IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
-    ULONG refCount = InterlockedIncrement(&This->ref);
+    ULONG ref = InterlockedIncrement(&This->ref);
 
-    TRACE("(%p)->(ref before=%u)\n", This, refCount - 1);
+    TRACE("(%p) ref=%u\n", This, ref);
 
-    return refCount;
+    return ref;
 }
 
 static ULONG WINAPI IDirectPlay8AddressImpl_Release(IDirectPlay8Address *iface)
 {
     IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
-    ULONG refCount = InterlockedDecrement(&This->ref);
+    ULONG ref = InterlockedDecrement(&This->ref);
 
-    TRACE("(%p)->(ref before=%u)\n", This, refCount + 1);
+    TRACE("(%p) ref=%u\n", This, ref);
 
-    if (!refCount) {
+    if (!ref) {
         HeapFree(GetProcessHeap(), 0, This);
     }
-    return refCount;
+    return ref;
 }
 
 /* returns name of given GUID */
@@ -312,17 +312,24 @@ static const IDirectPlay8AddressVtbl DirectPlay8Address_Vtbl =
     IDirectPlay8AddressImpl_BuildFromDirectPlay4Address
 };
 
-HRESULT DPNET_CreateDirectPlay8Address(LPCLASSFACTORY iface, LPUNKNOWN punkOuter, REFIID riid, LPVOID *ppobj) {
-  IDirectPlay8AddressImpl* client;
+HRESULT DPNET_CreateDirectPlay8Address(IClassFactory *iface, IUnknown *pUnkOuter, REFIID riid, LPVOID *ppobj)
+{
+    IDirectPlay8AddressImpl* client;
+    HRESULT ret;
 
-  TRACE("(%p, %s, %p)\n", punkOuter, debugstr_guid(riid), ppobj);
-  
-  client = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectPlay8AddressImpl));
-  if (NULL == client) {
-    *ppobj = NULL;
-    return E_OUTOFMEMORY;
-  }
-  client->IDirectPlay8Address_iface.lpVtbl = &DirectPlay8Address_Vtbl;
-  client->ref = 0; /* will be inited with QueryInterface */
-  return IDirectPlay8AddressImpl_QueryInterface (&client->IDirectPlay8Address_iface, riid, ppobj);
+    TRACE("(%p, %s, %p)\n", pUnkOuter, debugstr_guid(riid), ppobj);
+
+     *ppobj = NULL;
+
+    client = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectPlay8AddressImpl));
+    if (!client)
+        return E_OUTOFMEMORY;
+
+    client->IDirectPlay8Address_iface.lpVtbl = &DirectPlay8Address_Vtbl;
+    client->ref = 1;
+
+    ret = IDirectPlay8AddressImpl_QueryInterface(&client->IDirectPlay8Address_iface, riid, ppobj);
+    IDirectPlay8AddressImpl_Release(&client->IDirectPlay8Address_iface);
+
+    return ret;
 }




More information about the wine-cvs mailing list