Michael Stefaniuc : ddrawex: COM cleanup for the IDirectDrawFactory iface.
Alexandre Julliard
julliard at winehq.org
Mon Jan 24 11:07:32 CST 2011
Module: wine
Branch: master
Commit: 0b9cfcfcc956d21320889ac0369498c22c09c7db
URL: http://source.winehq.org/git/wine.git/?a=commit;h=0b9cfcfcc956d21320889ac0369498c22c09c7db
Author: Michael Stefaniuc <mstefani at redhat.de>
Date: Sun Jan 23 21:02:50 2011 +0100
ddrawex: COM cleanup for the IDirectDrawFactory iface.
---
dlls/ddrawex/ddrawex_private.h | 9 ---------
dlls/ddrawex/main.c | 37 ++++++++++++++++++++++++-------------
2 files changed, 24 insertions(+), 22 deletions(-)
diff --git a/dlls/ddrawex/ddrawex_private.h b/dlls/ddrawex/ddrawex_private.h
index 079b26c..34608c6 100644
--- a/dlls/ddrawex/ddrawex_private.h
+++ b/dlls/ddrawex/ddrawex_private.h
@@ -44,15 +44,6 @@ DECLARE_INTERFACE_(IDirectDrawFactory, IUnknown)
#endif
-/******************************************************************************
- * DirectDrawFactory implementation
- ******************************************************************************/
-typedef struct
-{
- const IDirectDrawFactoryVtbl *lpVtbl;
- LONG ref;
-} IDirectDrawFactoryImpl;
-
HRESULT WINAPI IDirectDrawFactoryImpl_CreateDirectDraw(IDirectDrawFactory* iface,
GUID * pGUID, HWND hWnd, DWORD dwCoopLevelFlags, DWORD dwReserved, IUnknown *pUnkOuter,
IDirectDraw **ppDirectDraw);
diff --git a/dlls/ddrawex/main.c b/dlls/ddrawex/main.c
index b5923e2..7b32323 100644
--- a/dlls/ddrawex/main.c
+++ b/dlls/ddrawex/main.c
@@ -150,16 +150,28 @@ static const IClassFactoryVtbl IClassFactory_Vtbl =
};
+/******************************************************************************
+ * DirectDrawFactory implementation
+ ******************************************************************************/
+typedef struct
+{
+ IDirectDrawFactory IDirectDrawFactory_iface;
+ LONG ref;
+} IDirectDrawFactoryImpl;
+
+static inline IDirectDrawFactoryImpl *impl_from_IDirectDrawFactory(IDirectDrawFactory *iface)
+{
+ return CONTAINING_RECORD(iface, IDirectDrawFactoryImpl, IDirectDrawFactory_iface);
+}
+
/*******************************************************************************
* IDirectDrawFactory::QueryInterface
*
*******************************************************************************/
-static HRESULT WINAPI
-IDirectDrawFactoryImpl_QueryInterface(IDirectDrawFactory *iface,
- REFIID riid,
- void **obj)
+static HRESULT WINAPI IDirectDrawFactoryImpl_QueryInterface(IDirectDrawFactory *iface, REFIID riid,
+ void **obj)
{
- IDirectDrawFactoryImpl *This = (IDirectDrawFactoryImpl*) iface;
+ IDirectDrawFactoryImpl *This = impl_from_IDirectDrawFactory(iface);
TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), obj);
@@ -179,10 +191,9 @@ IDirectDrawFactoryImpl_QueryInterface(IDirectDrawFactory *iface,
* IDirectDrawFactory::AddRef
*
*******************************************************************************/
-static ULONG WINAPI
-IDirectDrawFactoryImpl_AddRef(IDirectDrawFactory *iface)
+static ULONG WINAPI IDirectDrawFactoryImpl_AddRef(IDirectDrawFactory *iface)
{
- IDirectDrawFactoryImpl *This = (IDirectDrawFactoryImpl*) iface;
+ IDirectDrawFactoryImpl *This = impl_from_IDirectDrawFactory(iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p)->() incrementing from %d.\n", This, ref - 1);
@@ -194,11 +205,11 @@ IDirectDrawFactoryImpl_AddRef(IDirectDrawFactory *iface)
* IDirectDrawFactory::Release
*
*******************************************************************************/
-static ULONG WINAPI
-IDirectDrawFactoryImpl_Release(IDirectDrawFactory *iface)
+static ULONG WINAPI IDirectDrawFactoryImpl_Release(IDirectDrawFactory *iface)
{
- IDirectDrawFactoryImpl *This = (IDirectDrawFactoryImpl*) iface;
+ IDirectDrawFactoryImpl *This = impl_from_IDirectDrawFactory(iface);
ULONG ref = InterlockedDecrement(&This->ref);
+
TRACE("(%p)->() decrementing from %d.\n", This, ref+1);
if (ref == 0)
@@ -255,9 +266,9 @@ CreateDirectDrawFactory(IUnknown* UnkOuter, REFIID iid, void **obj)
return E_OUTOFMEMORY;
}
- This->lpVtbl = &IDirectDrawFactory_Vtbl;
+ This->IDirectDrawFactory_iface.lpVtbl = &IDirectDrawFactory_Vtbl;
- hr = IDirectDrawFactory_QueryInterface((IDirectDrawFactory *)This, iid, obj);
+ hr = IDirectDrawFactory_QueryInterface(&This->IDirectDrawFactory_iface, iid, obj);
if (FAILED(hr))
HeapFree(GetProcessHeap(), 0, This);
More information about the wine-cvs
mailing list