Rob Shearman : msi: Fix the value parameter of IWineMsiRemotePackage:: FormatRecord to have the right level of indirection for an [out] parameter.

Alexandre Julliard julliard at winehq.org
Thu Apr 17 07:38:21 CDT 2008


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

Author: Rob Shearman <rob at codeweavers.com>
Date:   Wed Apr 16 17:22:52 2008 +0100

msi: Fix the value parameter of IWineMsiRemotePackage::FormatRecord to have the right level of indirection for an [out] parameter.

Remove the redundant size parameter and simplify the client code such 
that the remote function is only called once, with the value being 
automatically allocated. Add corresponding code on the server side to 
automatically allocate said value.

---

 dlls/msi/format.c      |   17 +----------------
 dlls/msi/msiserver.idl |    2 +-
 dlls/msi/package.c     |   13 +++++++++++--
 3 files changed, 13 insertions(+), 19 deletions(-)

diff --git a/dlls/msi/format.c b/dlls/msi/format.c
index f58f517..454142a 100644
--- a/dlls/msi/format.c
+++ b/dlls/msi/format.c
@@ -921,28 +921,13 @@ UINT WINAPI MsiFormatRecordW( MSIHANDLE hInstall, MSIHANDLE hRecord,
         HRESULT hr;
         IWineMsiRemotePackage *remote_package;
         BSTR value = NULL;
-        DWORD len;
         awstring wstr;
 
         remote_package = (IWineMsiRemotePackage *)msi_get_remote( hInstall );
         if (remote_package)
         {
-            len = 0;
             hr = IWineMsiRemotePackage_FormatRecord( remote_package, hRecord,
-                                                     NULL, &len );
-            if (FAILED(hr))
-                goto done;
-
-            len++;
-            value = SysAllocStringLen( NULL, len );
-            if (!value)
-            {
-                r = ERROR_OUTOFMEMORY;
-                goto done;
-            }
-
-            hr = IWineMsiRemotePackage_FormatRecord( remote_package, hRecord,
-                                                     value, &len );
+                                                     &value );
             if (FAILED(hr))
                 goto done;
 
diff --git a/dlls/msi/msiserver.idl b/dlls/msi/msiserver.idl
index d5b47ac..37aa91e 100644
--- a/dlls/msi/msiserver.idl
+++ b/dlls/msi/msiserver.idl
@@ -70,7 +70,7 @@ interface IWineMsiRemotePackage : IUnknown
     HRESULT SetComponentState( [in] BSTR component, [in] INSTALLSTATE state );
     HRESULT GetLanguage( [out] LANGID *language );
     HRESULT SetInstallLevel( [in] int level );
-    HRESULT FormatRecord( [in] MSIHANDLE record, [out] BSTR value, [out] DWORD *size );
+    HRESULT FormatRecord( [in] MSIHANDLE record, [out] BSTR *value );
     HRESULT EvaluateCondition( [in] BSTR condition );
 }
 
diff --git a/dlls/msi/package.c b/dlls/msi/package.c
index a587a63..f11b068 100644
--- a/dlls/msi/package.c
+++ b/dlls/msi/package.c
@@ -1812,10 +1812,19 @@ static HRESULT WINAPI mrp_SetInstallLevel( IWineMsiRemotePackage *iface, int lev
 }
 
 static HRESULT WINAPI mrp_FormatRecord( IWineMsiRemotePackage *iface, MSIHANDLE record,
-                                 BSTR value, DWORD *size )
+                                        BSTR *value)
 {
+    DWORD size = 0;
     msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
-    UINT r = MsiFormatRecordW(This->package, record, (LPWSTR)value, size);
+    UINT r = MsiFormatRecordW(This->package, record, NULL, &size);
+    if (r == ERROR_SUCCESS)
+    {
+        *value = SysAllocStringLen(NULL, size);
+        if (!*value)
+            return E_OUTOFMEMORY;
+        size++;
+        r = MsiFormatRecordW(This->package, record, *value, &size);
+    }
     return HRESULT_FROM_WIN32(r);
 }
 




More information about the wine-cvs mailing list