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.
This commit is contained in:
Rob Shearman 2008-04-16 17:22:52 +01:00 committed by Alexandre Julliard
parent 1eece6eee6
commit 4a75b8bf09
3 changed files with 13 additions and 19 deletions

View File

@ -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;

View File

@ -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 );
}

View File

@ -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);
}