From: Alistair Leslie-Hughes Subject: dpnet: Cleanup IDirectPlay8Client Message-Id: <52DC915F.7030102@hotmail.com> Date: Mon, 20 Jan 2014 14:00:47 +1100 Hi, Changelog: dpnet: Cleanup IDirectPlay8Client Best Regards Alistair Leslie-Hughes >From 6240369f2b8cd67bbbd94c0f154753ce6d9ac92b Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Fri, 17 Jan 2014 14:38:34 +1100 Subject: [PATCH] Cleanup IDirectPlay8Client To: wine-patches --- dlls/dpnet/client.c | 56 +++++++++++++++++++++++++++++----------------- dlls/dpnet/dpnet_private.h | 15 ------------- 2 files changed, 36 insertions(+), 35 deletions(-) diff --git a/dlls/dpnet/client.c b/dlls/dpnet/client.c index 637dcb8..3307321 100644 --- a/dlls/dpnet/client.c +++ b/dlls/dpnet/client.c @@ -36,6 +36,12 @@ WINE_DEFAULT_DEBUG_CHANNEL(dpnet); +typedef struct IDirectPlay8ClientImpl +{ + IDirectPlay8Client IDirectPlay8Client_iface; + LONG ref; +} IDirectPlay8ClientImpl; + static inline IDirectPlay8ClientImpl *impl_from_IDirectPlay8Client(IDirectPlay8Client *iface) { return CONTAINING_RECORD(iface, IDirectPlay8ClientImpl, IDirectPlay8Client_iface); @@ -61,24 +67,24 @@ static HRESULT WINAPI IDirectPlay8ClientImpl_QueryInterface(IDirectPlay8Client * static ULONG WINAPI IDirectPlay8ClientImpl_AddRef(IDirectPlay8Client *iface) { IDirectPlay8ClientImpl *This = impl_from_IDirectPlay8Client(iface); - ULONG refCount = InterlockedIncrement(&This->ref); + ULONG ref = InterlockedIncrement(&This->ref); - TRACE("(%p)->(ref before=%u)\n", This, refCount - 1); + TRACE("(%p) ref=%d\n", This, ref); - return refCount; + return ref; } static ULONG WINAPI IDirectPlay8ClientImpl_Release(IDirectPlay8Client *iface) { IDirectPlay8ClientImpl *This = impl_from_IDirectPlay8Client(iface); - ULONG refCount = InterlockedDecrement(&This->ref); + ULONG ref = InterlockedDecrement(&This->ref); - TRACE("(%p)->(ref before=%u)\n", This, refCount + 1); + TRACE("(%p) ref=%d\n", This, ref);; - if (!refCount) { + if (!ref) { HeapFree(GetProcessHeap(), 0, This); } - return refCount; + return ref; } /* IDirectPlay8Client Interface follow: */ @@ -273,17 +279,27 @@ static const IDirectPlay8ClientVtbl DirectPlay8Client_Vtbl = IDirectPlay8ClientImpl_RegisterLobby }; -HRESULT DPNET_CreateDirectPlay8Client(LPCLASSFACTORY iface, LPUNKNOWN punkOuter, REFIID riid, LPVOID *ppobj) { - IDirectPlay8ClientImpl* client; - - TRACE("(%p, %s, %p)\n", punkOuter, debugstr_guid(riid), ppobj); - - client = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectPlay8ClientImpl)); - if (NULL == client) { - *ppobj = NULL; - return E_OUTOFMEMORY; - } - client->IDirectPlay8Client_iface.lpVtbl = &DirectPlay8Client_Vtbl; - client->ref = 0; /* will be inited with QueryInterface */ - return IDirectPlay8ClientImpl_QueryInterface(&client->IDirectPlay8Client_iface, riid, ppobj); +HRESULT DPNET_CreateDirectPlay8Client(IClassFactory *iface, IUnknown *pUnkOuter, REFIID riid, void **ppv) +{ + IDirectPlay8ClientImpl* client; + HRESULT hr; + + TRACE("(%p, %s, %p)\n", pUnkOuter, debugstr_guid(riid), ppv); + + *ppv = NULL; + + if(pUnkOuter) + return CLASS_E_NOAGGREGATION; + + client = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectPlay8ClientImpl)); + if (!client) + return E_OUTOFMEMORY; + + client->IDirectPlay8Client_iface.lpVtbl = &DirectPlay8Client_Vtbl; + client->ref = 1; + + hr = IDirectPlay8ClientImpl_QueryInterface(&client->IDirectPlay8Client_iface, riid, ppv); + IDirectPlay8ClientImpl_Release(&client->IDirectPlay8Client_iface); + + return hr; } diff --git a/dlls/dpnet/dpnet_private.h b/dlls/dpnet/dpnet_private.h index 4a42eae..dbfc1a7 100644 --- a/dlls/dpnet/dpnet_private.h +++ b/dlls/dpnet/dpnet_private.h @@ -32,25 +32,10 @@ */ /* DirectPlay8 Interfaces: */ -typedef struct IDirectPlay8ClientImpl IDirectPlay8ClientImpl; typedef struct IDirectPlay8AddressImpl IDirectPlay8AddressImpl; typedef struct IDirectPlay8LobbiedApplicationImpl IDirectPlay8LobbiedApplicationImpl; typedef struct IDirectPlay8ThreadPoolImpl IDirectPlay8ThreadPoolImpl; -/* ------------------ */ -/* IDirectPlay8Client */ -/* ------------------ */ - -/***************************************************************************** - * IDirectPlay8Client implementation structure - */ -struct IDirectPlay8ClientImpl -{ - IDirectPlay8Client IDirectPlay8Client_iface; - LONG ref; - /* IDirectPlay8Client fields */ -}; - /* ------------------- */ /* IDirectPlay8Address */ /* ------------------- */ -- 1.8.3.2