Nikolay Sivov : scrrun: Store collection pointer directly in IEnumVARIANT data.

Alexandre Julliard julliard at winehq.org
Wed Jan 8 13:41:31 CST 2014


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

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Wed Jan  8 12:36:54 2014 +0400

scrrun: Store collection pointer directly in IEnumVARIANT data.

---

 dlls/scrrun/filesystem.c |   66 +++++++++++++++++-----------------------------
 1 file changed, 24 insertions(+), 42 deletions(-)

diff --git a/dlls/scrrun/filesystem.c b/dlls/scrrun/filesystem.c
index eb9073a..4802614 100644
--- a/dlls/scrrun/filesystem.c
+++ b/dlls/scrrun/filesystem.c
@@ -38,20 +38,30 @@ WINE_DEFAULT_DEBUG_CHANNEL(scrrun);
 
 static const WCHAR bsW[] = {'\\',0};
 
+struct foldercollection {
+    IFolderCollection IFolderCollection_iface;
+    LONG ref;
+    BSTR path;
+};
+
+struct filecollection {
+    IFileCollection IFileCollection_iface;
+    LONG ref;
+    BSTR path;
+};
+
 struct enumdata {
     union
     {
         struct
         {
-            IFolderCollection *coll;
+            struct foldercollection *coll;
             HANDLE find;
-            BSTR path;
         } foldercoll;
         struct
         {
-            IFileCollection *coll;
+            struct filecollection *coll;
             HANDLE find;
-            BSTR path;
         } filecoll;
     } u;
 };
@@ -63,18 +73,6 @@ struct enumvariant {
     struct enumdata data;
 };
 
-struct foldercollection {
-    IFolderCollection IFolderCollection_iface;
-    LONG ref;
-    BSTR path;
-};
-
-struct filecollection {
-    IFileCollection IFileCollection_iface;
-    LONG ref;
-    BSTR path;
-};
-
 struct folder {
     IFolder IFolder_iface;
     LONG ref;
@@ -459,8 +457,7 @@ static ULONG WINAPI foldercoll_enumvariant_Release(IEnumVARIANT *iface)
 
     if (!ref)
     {
-        IFolderCollection_Release(This->data.u.foldercoll.coll);
-        SysFreeString(This->data.u.foldercoll.path);
+        IFolderCollection_Release(&This->data.u.foldercoll.coll->IFolderCollection_iface);
         FindClose(This->data.u.foldercoll.find);
         heap_free(This);
     }
@@ -484,7 +481,7 @@ static HRESULT WINAPI foldercoll_enumvariant_Next(IEnumVARIANT *iface, ULONG cel
     {
         static const WCHAR allW[] = {'*',0};
         WCHAR pathW[MAX_PATH];
-        BSTR parent = This->data.u.foldercoll.path;
+        BSTR parent = This->data.u.foldercoll.coll->path;
         int len;
 
         strcpyW(pathW, parent);
@@ -522,7 +519,7 @@ static HRESULT WINAPI foldercoll_enumvariant_Next(IEnumVARIANT *iface, ULONG cel
             HRESULT hr;
             BSTR str;
 
-            str = get_full_path(This->data.u.foldercoll.path, &data);
+            str = get_full_path(This->data.u.foldercoll.coll->path, &data);
             hr = create_folder(str, &folder);
             SysFreeString(str);
             if (FAILED(hr)) return hr;
@@ -598,15 +595,8 @@ static HRESULT create_foldercoll_enum(struct foldercollection *collection, IUnkn
     This->IEnumVARIANT_iface.lpVtbl = &foldercollenumvariantvtbl;
     This->ref = 1;
     This->data.u.foldercoll.find = NULL;
-    This->data.u.foldercoll.path = SysAllocString(collection->path);
-    if (!This->data.u.foldercoll.path)
-    {
-        heap_free(This);
-        return E_OUTOFMEMORY;
-    }
-
-    This->data.u.foldercoll.coll = &collection->IFolderCollection_iface;
-    IFolderCollection_AddRef(This->data.u.foldercoll.coll);
+    This->data.u.foldercoll.coll = collection;
+    IFolderCollection_AddRef(&collection->IFolderCollection_iface);
 
     *newenum = (IUnknown*)&This->IEnumVARIANT_iface;
 
@@ -622,8 +612,7 @@ static ULONG WINAPI filecoll_enumvariant_Release(IEnumVARIANT *iface)
 
     if (!ref)
     {
-        IFileCollection_Release(This->data.u.filecoll.coll);
-        SysFreeString(This->data.u.filecoll.path);
+        IFileCollection_Release(&This->data.u.filecoll.coll->IFileCollection_iface);
         heap_free(This);
     }
 
@@ -646,7 +635,7 @@ static HRESULT WINAPI filecoll_enumvariant_Next(IEnumVARIANT *iface, ULONG celt,
     {
         static const WCHAR allW[] = {'*',0};
         WCHAR pathW[MAX_PATH];
-        BSTR parent = This->data.u.filecoll.path;
+        BSTR parent = This->data.u.filecoll.coll->path;
         int len;
 
         strcpyW(pathW, parent);
@@ -683,7 +672,7 @@ static HRESULT WINAPI filecoll_enumvariant_Next(IEnumVARIANT *iface, ULONG celt,
             HRESULT hr;
             BSTR str;
 
-            str = get_full_path(This->data.u.filecoll.path, &data);
+            str = get_full_path(This->data.u.filecoll.coll->path, &data);
             hr = create_file(str, &file);
             SysFreeString(str);
             if (FAILED(hr)) return hr;
@@ -758,15 +747,8 @@ static HRESULT create_filecoll_enum(struct filecollection *collection, IUnknown
 
     This->IEnumVARIANT_iface.lpVtbl = &filecollenumvariantvtbl;
     This->ref = 1;
-    This->data.u.filecoll.path = SysAllocString(collection->path);
-    if (!This->data.u.filecoll.path)
-    {
-        heap_free(This);
-        return E_OUTOFMEMORY;
-    }
-
-    This->data.u.filecoll.coll = &collection->IFileCollection_iface;
-    IFileCollection_AddRef(This->data.u.filecoll.coll);
+    This->data.u.filecoll.coll = collection;
+    IFileCollection_AddRef(&collection->IFileCollection_iface);
 
     *newenum = (IUnknown*)&This->IEnumVARIANT_iface;
 




More information about the wine-cvs mailing list