Michael Stefaniuc : windowscodecs: Use an iface instead of a vtbl pointer in PropertyBag.

Alexandre Julliard julliard at winehq.org
Thu Dec 9 12:26:25 CST 2010


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

Author: Michael Stefaniuc <mstefani at redhat.de>
Date:   Wed Dec  8 22:59:37 2010 +0100

windowscodecs: Use an iface instead of a vtbl pointer in PropertyBag.

---

 dlls/windowscodecs/propertybag.c |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/dlls/windowscodecs/propertybag.c b/dlls/windowscodecs/propertybag.c
index ca40b3b..43c88c7 100644
--- a/dlls/windowscodecs/propertybag.c
+++ b/dlls/windowscodecs/propertybag.c
@@ -34,14 +34,19 @@
 WINE_DEFAULT_DEBUG_CHANNEL(wincodecs);
 
 typedef struct PropertyBag {
-    const IPropertyBag2Vtbl *lpVtbl;
+    IPropertyBag2 IPropertyBag2_iface;
     LONG ref;
 } PropertyBag;
 
+static inline PropertyBag *impl_from_IPropertyBag2(IPropertyBag2 *iface)
+{
+    return CONTAINING_RECORD(iface, PropertyBag, IPropertyBag2_iface);
+}
+
 static HRESULT WINAPI PropertyBag_QueryInterface(IPropertyBag2 *iface, REFIID iid,
     void **ppv)
 {
-    PropertyBag *This = (PropertyBag*)iface;
+    PropertyBag *This = impl_from_IPropertyBag2(iface);
     TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
 
     if (!ppv) return E_INVALIDARG;
@@ -63,7 +68,7 @@ static HRESULT WINAPI PropertyBag_QueryInterface(IPropertyBag2 *iface, REFIID ii
 
 static ULONG WINAPI PropertyBag_AddRef(IPropertyBag2 *iface)
 {
-    PropertyBag *This = (PropertyBag*)iface;
+    PropertyBag *This = impl_from_IPropertyBag2(iface);
     ULONG ref = InterlockedIncrement(&This->ref);
 
     TRACE("(%p) refcount=%u\n", iface, ref);
@@ -73,7 +78,7 @@ static ULONG WINAPI PropertyBag_AddRef(IPropertyBag2 *iface)
 
 static ULONG WINAPI PropertyBag_Release(IPropertyBag2 *iface)
 {
-    PropertyBag *This = (PropertyBag*)iface;
+    PropertyBag *This = impl_from_IPropertyBag2(iface);
     ULONG ref = InterlockedDecrement(&This->ref);
 
     TRACE("(%p) refcount=%u\n", iface, ref);
@@ -138,10 +143,10 @@ extern HRESULT CreatePropertyBag2(IPropertyBag2 **ppPropertyBag2)
     This = HeapAlloc(GetProcessHeap(), 0, sizeof(PropertyBag));
     if (!This) return E_OUTOFMEMORY;
 
-    This->lpVtbl = &PropertyBag_Vtbl;
+    This->IPropertyBag2_iface.lpVtbl = &PropertyBag_Vtbl;
     This->ref = 1;
 
-    *ppPropertyBag2 = (IPropertyBag2*)This;
+    *ppPropertyBag2 = &This->IPropertyBag2_iface;
 
     return S_OK;
 }




More information about the wine-cvs mailing list