Michael Stefaniuc : hlink: Use an iface instead of a vtbl pointer in CFImpl .

Alexandre Julliard julliard at winehq.org
Thu Dec 30 10:49:55 CST 2010


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

Author: Michael Stefaniuc <mstefani at redhat.de>
Date:   Thu Dec 30 01:52:04 2010 +0100

hlink: Use an iface instead of a vtbl pointer in CFImpl.

---

 dlls/hlink/hlink_main.c |   21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/dlls/hlink/hlink_main.c b/dlls/hlink/hlink_main.c
index 0300fc0..d547daa 100644
--- a/dlls/hlink/hlink_main.c
+++ b/dlls/hlink/hlink_main.c
@@ -34,10 +34,15 @@ typedef HRESULT (CALLBACK *LPFNCREATEINSTANCE)(IUnknown*, REFIID, LPVOID*);
 
 typedef struct
 {
-    const IClassFactoryVtbl *lpVtbl;
-    LPFNCREATEINSTANCE      lpfnCI;
+    IClassFactory      IClassFactory_iface;
+    LPFNCREATEINSTANCE lpfnCI;
 } CFImpl;
 
+static inline CFImpl *impl_from_IClassFactory(IClassFactory *iface)
+{
+    return CONTAINING_RECORD(iface, CFImpl, IClassFactory_iface);
+}
+
 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
 {
     TRACE("%p %d %p\n", hinstDLL, fdwReason, lpvReserved);
@@ -500,7 +505,7 @@ cleanup:
 static HRESULT WINAPI HLinkCF_fnQueryInterface ( LPCLASSFACTORY iface,
         REFIID riid, LPVOID *ppvObj)
 {
-    CFImpl *This = (CFImpl *)iface;
+    CFImpl *This = impl_from_IClassFactory(iface);
 
     TRACE("(%p)->(%s)\n",This,debugstr_guid(riid));
 
@@ -530,7 +535,7 @@ static ULONG WINAPI HLinkCF_fnRelease(LPCLASSFACTORY iface)
 static HRESULT WINAPI HLinkCF_fnCreateInstance( LPCLASSFACTORY iface,
         LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObject)
 {
-    CFImpl *This = (CFImpl *)iface;
+    CFImpl *This = impl_from_IClassFactory(iface);
 
     TRACE("%p->(%p,%s,%p)\n", This, pUnkOuter, debugstr_guid(riid), ppvObject);
 
@@ -554,8 +559,8 @@ static const IClassFactoryVtbl hlcfvt =
     HLinkCF_fnLockServer
 };
 
-static CFImpl HLink_cf = { &hlcfvt, HLink_Constructor };
-static CFImpl HLinkBrowseContext_cf = { &hlcfvt, HLinkBrowseContext_Constructor };
+static CFImpl HLink_cf = { { &hlcfvt }, HLink_Constructor };
+static CFImpl HLinkBrowseContext_cf = { { &hlcfvt }, HLinkBrowseContext_Constructor };
 
 /***********************************************************************
  *             DllGetClassObject (HLINK.@)
@@ -571,9 +576,9 @@ HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
     *ppv = NULL;
 
     if (IsEqualIID(rclsid, &CLSID_StdHlink))
-        pcf = (IClassFactory*) &HLink_cf;
+        pcf = &HLink_cf.IClassFactory_iface;
     else if (IsEqualIID(rclsid, &CLSID_StdHlinkBrowseContext))
-        pcf = (IClassFactory*) &HLinkBrowseContext_cf;
+        pcf = &HLinkBrowseContext_cf.IClassFactory_iface;
     else
         return CLASS_E_CLASSNOTAVAILABLE;
 




More information about the wine-cvs mailing list