Nikolay Sivov : ole32: COM cleanup of IPropertySetStorage interface.

Alexandre Julliard julliard at winehq.org
Mon Jul 16 14:14:28 CDT 2012


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

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Sat Jul 14 20:42:48 2012 +0400

ole32: COM cleanup of IPropertySetStorage interface.

---

 dlls/ole32/stg_prop.c   |   16 +++++++---------
 dlls/ole32/stg_stream.c |    4 ++--
 dlls/ole32/storage32.c  |   13 ++++++-------
 dlls/ole32/storage32.h  |    2 +-
 4 files changed, 16 insertions(+), 19 deletions(-)

diff --git a/dlls/ole32/stg_prop.c b/dlls/ole32/stg_prop.c
index 5e22a40..9e3df45 100644
--- a/dlls/ole32/stg_prop.c
+++ b/dlls/ole32/stg_prop.c
@@ -60,7 +60,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(storage);
 
 static inline StorageImpl *impl_from_IPropertySetStorage( IPropertySetStorage *iface )
 {
-    return (StorageImpl *)((char*)iface - FIELD_OFFSET(StorageImpl, base.pssVtbl));
+    return CONTAINING_RECORD(iface, StorageImpl, base.IPropertySetStorage_iface);
 }
 
 /* These are documented in MSDN,
@@ -2100,7 +2100,7 @@ static HRESULT WINAPI IPropertySetStorage_fnQueryInterface(
     void** ppvObject)
 {
     StorageImpl *This = impl_from_IPropertySetStorage(ppstg);
-    return IStorage_QueryInterface( (IStorage*)This, riid, ppvObject );
+    return IStorage_QueryInterface( &This->base.IStorage_iface, riid, ppvObject );
 }
 
 /************************************************************************
@@ -2112,7 +2112,7 @@ static ULONG WINAPI IPropertySetStorage_fnAddRef(
     IPropertySetStorage *ppstg)
 {
     StorageImpl *This = impl_from_IPropertySetStorage(ppstg);
-    return IStorage_AddRef( (IStorage*)This );
+    return IStorage_AddRef( &This->base.IStorage_iface );
 }
 
 /************************************************************************
@@ -2124,7 +2124,7 @@ static ULONG WINAPI IPropertySetStorage_fnRelease(
     IPropertySetStorage *ppstg)
 {
     StorageImpl *This = impl_from_IPropertySetStorage(ppstg);
-    return IStorage_Release( (IStorage*)This );
+    return IStorage_Release( &This->base.IStorage_iface );
 }
 
 /************************************************************************
@@ -2173,7 +2173,7 @@ static HRESULT WINAPI IPropertySetStorage_fnCreate(
     if (FAILED(r))
         goto end;
 
-    r = IStorage_CreateStream( (IStorage*)This, name, grfMode, 0, 0, &stm );
+    r = IStorage_CreateStream( &This->base.IStorage_iface, name, grfMode, 0, 0, &stm );
     if (FAILED(r))
         goto end;
 
@@ -2218,7 +2218,7 @@ static HRESULT WINAPI IPropertySetStorage_fnOpen(
     if (FAILED(r))
         goto end;
 
-    r = IStorage_OpenStream((IStorage*) This, name, 0, grfMode, 0, &stm );
+    r = IStorage_OpenStream( &This->base.IStorage_iface, name, 0, grfMode, 0, &stm );
     if (FAILED(r))
         goto end;
 
@@ -2237,7 +2237,6 @@ static HRESULT WINAPI IPropertySetStorage_fnDelete(
     REFFMTID rfmtid)
 {
     StorageImpl *This = impl_from_IPropertySetStorage(ppstg);
-    IStorage *stg = NULL;
     WCHAR name[CCH_MAX_PROPSTG_NAME];
     HRESULT r;
 
@@ -2250,8 +2249,7 @@ static HRESULT WINAPI IPropertySetStorage_fnDelete(
     if (FAILED(r))
         return r;
 
-    stg = (IStorage*) This;
-    return IStorage_DestroyElement(stg, name);
+    return IStorage_DestroyElement(&This->base.IStorage_iface, name);
 }
 
 /************************************************************************
diff --git a/dlls/ole32/stg_stream.c b/dlls/ole32/stg_stream.c
index 019a789..6a39b94 100644
--- a/dlls/ole32/stg_stream.c
+++ b/dlls/ole32/stg_stream.c
@@ -57,7 +57,7 @@ static void StgStreamImpl_Destroy(StgStreamImpl* This)
 
   /*
    * Release the reference we are holding on the parent storage.
-   * IStorage_Release((IStorage*)This->parentStorage);
+   * IStorage_Release(&This->parentStorage->IStorage_iface);
    *
    * No, don't do this. Some apps call IStorage_Release without
    * calling IStream_Release first. If we grab a reference the
@@ -719,7 +719,7 @@ StgStreamImpl* StgStreamImpl_Construct(
      * We want to nail-down the reference to the storage in case the
      * stream out-lives the storage in the client application.
      *
-     * -- IStorage_AddRef((IStorage*)newStream->parentStorage);
+     * -- IStorage_AddRef(&newStream->parentStorage->IStorage_iface);
      *
      * No, don't do this. Some apps call IStorage_Release without
      * calling IStream_Release first. If we grab a reference the
diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c
index 4e802f5..df84108 100644
--- a/dlls/ole32/storage32.c
+++ b/dlls/ole32/storage32.c
@@ -373,11 +373,11 @@ static HRESULT WINAPI StorageBaseImpl_QueryInterface(
   if (IsEqualGUID(&IID_IUnknown, riid) ||
       IsEqualGUID(&IID_IStorage, riid))
   {
-    *ppvObject = This;
+    *ppvObject = &This->IStorage_iface;
   }
   else if (IsEqualGUID(&IID_IPropertySetStorage, riid))
   {
-    *ppvObject = &This->pssVtbl;
+    *ppvObject = &This->IPropertySetStorage_iface;
   }
 
   if ((*ppvObject)==0)
@@ -2718,7 +2718,7 @@ static HRESULT StorageImpl_Construct(
   list_init(&This->base.storageHead);
 
   This->base.IStorage_iface.lpVtbl = &Storage32Impl_Vtbl;
-  This->base.pssVtbl = &IPropertySetStorage_Vtbl;
+  This->base.IPropertySetStorage_iface.lpVtbl = &IPropertySetStorage_Vtbl;
   This->base.baseVtbl = &StorageImpl_BaseVtbl;
   This->base.openFlags = (openFlags & ~STGM_CREATE);
   This->base.ref = 1;
@@ -5095,8 +5095,7 @@ static HRESULT TransactedSnapshotImpl_Construct(StorageBaseImpl *parentStorage,
     (*result)->base.IStorage_iface.lpVtbl = &TransactedSnapshotImpl_Vtbl;
 
     /* This is OK because the property set storage functions use the IStorage functions. */
-    (*result)->base.pssVtbl = parentStorage->pssVtbl;
-
+    (*result)->base.IPropertySetStorage_iface.lpVtbl = parentStorage->IPropertySetStorage_iface.lpVtbl;
     (*result)->base.baseVtbl = &TransactedSnapshotImpl_BaseVtbl;
 
     list_init(&(*result)->base.strmHead);
@@ -5693,7 +5692,7 @@ static StorageInternalImpl* StorageInternalImpl_Construct(
      * Initialize the virtual function table.
      */
     newStorage->base.IStorage_iface.lpVtbl = &Storage32InternalImpl_Vtbl;
-    newStorage->base.pssVtbl = &IPropertySetStorage_Vtbl;
+    newStorage->base.IPropertySetStorage_iface.lpVtbl = &IPropertySetStorage_Vtbl;
     newStorage->base.baseVtbl = &StorageInternalImpl_BaseVtbl;
     newStorage->base.openFlags = (openFlags & ~STGM_CREATE);
 
@@ -9519,7 +9518,7 @@ HRESULT WINAPI ReadClassStm(IStream *pStm,CLSID *pclsid)
     /* clear the output args */
     *pclsid = CLSID_NULL;
 
-    res = IStream_Read(pStm,(void*)pclsid,sizeof(CLSID),&nbByte);
+    res = IStream_Read(pStm, pclsid, sizeof(CLSID), &nbByte);
 
     if (FAILED(res))
         return res;
diff --git a/dlls/ole32/storage32.h b/dlls/ole32/storage32.h
index d94740d..80fe01b 100644
--- a/dlls/ole32/storage32.h
+++ b/dlls/ole32/storage32.h
@@ -176,7 +176,7 @@ HRESULT OLECONVERT_CreateCompObjStream(LPSTORAGE pStorage, LPCSTR strOleTypeName
 struct StorageBaseImpl
 {
   IStorage IStorage_iface;
-  const IPropertySetStorageVtbl *pssVtbl; /* interface for adding a properties stream */
+  IPropertySetStorage IPropertySetStorage_iface; /* interface for adding a properties stream */
   LONG ref;
 
   /*




More information about the wine-cvs mailing list