Commit 77a19ed8 authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

Replace instances of HeapAlloc/MultiByteToWideChar with the internally

defined strdupAtoW.
parent f8f64406
......@@ -86,11 +86,9 @@ UINT WINAPI MsiDatabaseOpenViewA(MSIHANDLE hdb,
if( szQuery )
{
UINT len = MultiByteToWideChar( CP_ACP, 0, szQuery, -1, NULL, 0 );
szwQuery = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
szwQuery = strdupAtoW( szQuery );
if( !szwQuery )
return ERROR_FUNCTION_FAILED;
MultiByteToWideChar( CP_ACP, 0, szQuery, -1, szwQuery, len );
}
else
szwQuery = NULL;
......@@ -672,16 +670,15 @@ UINT WINAPI MsiDatabaseGetPrimaryKeysA(MSIHANDLE hdb,
LPCSTR table, MSIHANDLE* phRec)
{
LPWSTR szwTable = NULL;
DWORD len;
UINT r;
TRACE("%ld %s %p\n", hdb, debugstr_a(table), phRec);
if( table )
{
len = MultiByteToWideChar( CP_ACP, 0, table, -1, NULL, 0 );
szwTable = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
MultiByteToWideChar( CP_ACP, 0, table, -1, szwTable, len );
szwTable = strdupAtoW( table );
if( !szwTable )
return ERROR_OUTOFMEMORY;
}
r = MsiDatabaseGetPrimaryKeysW( hdb, szwTable, phRec );
HeapFree( GetProcessHeap(), 0, szwTable );
......
......@@ -469,14 +469,13 @@ UINT WINAPI MsiOpenPackageW(LPCWSTR szPackage, MSIHANDLE *phPackage)
UINT WINAPI MsiOpenPackageExA(LPCSTR szPackage, DWORD dwOptions, MSIHANDLE *phPackage)
{
LPWSTR szwPack = NULL;
UINT len, ret;
UINT ret;
if( szPackage )
{
len = MultiByteToWideChar( CP_ACP, 0, szPackage, -1, NULL, 0 );
szwPack = HeapAlloc( GetProcessHeap(), 0, len * sizeof (WCHAR) );
if( szwPack )
MultiByteToWideChar( CP_ACP, 0, szPackage, -1, szwPack, len );
szwPack = strdupAtoW( szPackage );
if( !szwPack )
return ERROR_OUTOFMEMORY;
}
ret = MsiOpenPackageExW( szwPack, dwOptions, phPackage );
......@@ -638,29 +637,20 @@ UINT WINAPI MsiSetPropertyA( MSIHANDLE hInstall, LPCSTR szName, LPCSTR szValue)
{
LPWSTR szwName = NULL, szwValue = NULL;
UINT hr = ERROR_INSTALL_FAILURE;
UINT len;
if (0 == hInstall) {
return ERROR_INVALID_HANDLE;
}
if (NULL == szName) {
return ERROR_INVALID_PARAMETER;
}
if (NULL == szValue) {
return ERROR_INVALID_PARAMETER;
}
len = MultiByteToWideChar( CP_ACP, 0, szName, -1, NULL, 0 );
szwName = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
if( szName )
{
szwName = strdupAtoW( szName );
if( !szwName )
goto end;
MultiByteToWideChar( CP_ACP, 0, szName, -1, szwName, len );
}
len = MultiByteToWideChar( CP_ACP, 0, szValue, -1, NULL, 0 );
szwValue = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
if( szValue )
{
szwValue = strdupAtoW( szValue );
if( !szwValue)
goto end;
MultiByteToWideChar( CP_ACP, 0, szValue , -1, szwValue, len );
}
hr = MsiSetPropertyW( hInstall, szwName, szwValue);
......@@ -732,8 +722,13 @@ UINT WINAPI MsiSetPropertyW( MSIHANDLE hInstall, LPCWSTR szName, LPCWSTR szValue
MSIPACKAGE *package;
UINT ret;
if (NULL == szName)
return ERROR_INVALID_PARAMETER;
if (NULL == szValue)
return ERROR_INVALID_PARAMETER;
package = msihandle2msiinfo( hInstall, MSIHANDLETYPE_PACKAGE);
if( !package)
if( !package )
return ERROR_INVALID_HANDLE;
ret = MSI_SetPropertyW( package, szName, szValue);
msiobj_release( &package->hdr );
......@@ -808,17 +803,18 @@ UINT MSI_GetPropertyA(MSIPACKAGE *package, LPCSTR szName,
LPSTR szValueBuf, DWORD* pchValueBuf)
{
MSIRECORD *row;
UINT rc, len;
LPWSTR szwName;
UINT rc;
LPWSTR szwName = NULL;
if (*pchValueBuf > 0)
szValueBuf[0] = 0;
len = MultiByteToWideChar( CP_ACP, 0, szName, -1, NULL, 0 );
szwName = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
if( szName )
{
szwName = strdupAtoW( szName );
if (!szwName)
return ERROR_NOT_ENOUGH_MEMORY;
MultiByteToWideChar( CP_ACP, 0, szName, -1, szwName, len );
}
rc = MSI_GetPropertyRow(package, szwName, &row);
if (rc == ERROR_SUCCESS)
......
......@@ -132,16 +132,16 @@ UINT WINAPI MsiPreviewDialogW( MSIHANDLE hPreview, LPCWSTR szDialogName )
UINT WINAPI MsiPreviewDialogA( MSIHANDLE hPreview, LPCSTR szDialogName )
{
UINT r, len;
UINT r;
LPWSTR strW = NULL;
TRACE("%ld %s\n", hPreview, debugstr_a(szDialogName));
if( szDialogName )
{
len = MultiByteToWideChar( CP_ACP, 0, szDialogName, -1, NULL, 0 );
strW = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
MultiByteToWideChar( CP_ACP, 0, szDialogName, -1, strW, len );
strW = strdupAtoW( szDialogName );
if( !strW )
return ERROR_OUTOFMEMORY;
}
r = MsiPreviewDialogW( hPreview, strW );
HeapFree( GetProcessHeap(), 0, strW );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment