Hans Leidekker : msi: Get rid of global variables the cabinet extraction callbacks.

Alexandre Julliard julliard at wine.codeweavers.com
Wed Apr 1 10:40:59 CDT 2015


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

Author: Hans Leidekker <hans at codeweavers.com>
Date:   Wed Apr  1 12:33:36 2015 +0200

msi: Get rid of global variables the cabinet extraction callbacks.

---

 dlls/msi/files.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/dlls/msi/files.c b/dlls/msi/files.c
index b6833e9..d1e3ecf 100644
--- a/dlls/msi/files.c
+++ b/dlls/msi/files.c
@@ -278,12 +278,11 @@ static MSIFILE *find_file( MSIPACKAGE *package, UINT disk_id, const WCHAR *filen
 static BOOL installfiles_cb(MSIPACKAGE *package, LPCWSTR filename, DWORD action,
                             LPWSTR *path, DWORD *attrs, PVOID user)
 {
-    static MSIFILE *file = NULL;
-    UINT_PTR disk_id = (UINT_PTR)user;
+    MSIFILE *file = *(MSIFILE **)user;
 
     if (action == MSICABEXTRACT_BEGINEXTRACT)
     {
-        if (!(file = find_file( package, disk_id, filename )))
+        if (!(file = find_file( package, file->disk_id, filename )))
         {
             TRACE("unknown file in cabinet (%s)\n", debugstr_w(filename));
             return FALSE;
@@ -297,11 +296,11 @@ static BOOL installfiles_cb(MSIPACKAGE *package, LPCWSTR filename, DWORD action,
         }
         *path = strdupW( file->TargetPath );
         *attrs = file->Attributes;
+        *(MSIFILE **)user = file;
     }
     else if (action == MSICABEXTRACT_FILEEXTRACTED)
     {
         if (!msi_is_global_assembly( file->Component )) file->state = msifs_installed;
-        file = NULL;
     }
 
     return TRUE;
@@ -372,11 +371,12 @@ UINT ACTION_InstallFiles(MSIPACKAGE *package)
             (file->IsCompressed && !mi->is_extracted))
         {
             MSICABDATA data;
+            MSIFILE *cursor = file;
 
             data.mi = mi;
             data.package = package;
             data.cb = installfiles_cb;
-            data.user = (PVOID)(UINT_PTR)mi->disk_id;
+            data.user = &cursor;
 
             if (file->IsCompressed && !msi_cabextract(package, mi, &data))
             {
@@ -451,21 +451,20 @@ static MSIFILEPATCH *find_filepatch( MSIPACKAGE *package, UINT disk_id, const WC
 static BOOL patchfiles_cb(MSIPACKAGE *package, LPCWSTR file, DWORD action,
                           LPWSTR *path, DWORD *attrs, PVOID user)
 {
-    static MSIFILEPATCH *patch;
-    UINT_PTR disk_id = (UINT_PTR)user;
+    MSIFILEPATCH *patch = *(MSIFILEPATCH **)user;
 
     if (action == MSICABEXTRACT_BEGINEXTRACT)
     {
-        if (!(patch = find_filepatch( package, disk_id, file ))) return FALSE;
+        if (!(patch = find_filepatch( package, patch->disk_id, file ))) return FALSE;
 
         patch->path = msi_create_temp_file( package->db );
         *path = strdupW( patch->path );
         *attrs = patch->File->Attributes;
+        *(MSIFILEPATCH **)user = patch;
     }
     else if (action == MSICABEXTRACT_FILEEXTRACTED)
     {
         patch->extracted = TRUE;
-        patch = NULL;
     }
 
     return TRUE;
@@ -501,6 +500,7 @@ UINT ACTION_PatchFiles( MSIPACKAGE *package )
         if (!patch->extracted)
         {
             MSICABDATA data;
+            MSIFILEPATCH *cursor = patch;
 
             rc = ready_media( package, TRUE, mi );
             if (rc != ERROR_SUCCESS)
@@ -511,7 +511,7 @@ UINT ACTION_PatchFiles( MSIPACKAGE *package )
             data.mi      = mi;
             data.package = package;
             data.cb      = patchfiles_cb;
-            data.user    = (PVOID)(UINT_PTR)mi->disk_id;
+            data.user    = &cursor;
 
             if (!msi_cabextract( package, mi, &data ))
             {




More information about the wine-cvs mailing list