remove references to HEAP_strdupAtoW in msi

Mike McCormack mike at codeweavers.com
Sat Sep 27 17:31:36 CDT 2003


ChangeLog:
* remove references to HEAP_strdupAtoW in msi
-------------- next part --------------
Index: dlls/msi/msi.c
===================================================================
RCS file: /home/wine/wine/dlls/msi/msi.c,v
retrieving revision 1.4
diff -u -r1.4 msi.c
--- dlls/msi/msi.c	8 Sep 2003 19:38:46 -0000	1.4
+++ dlls/msi/msi.c	26 Sep 2003 19:05:47 -0000
@@ -1,7 +1,7 @@
 /*
  * Implementation of the Microsoft Installer (msi.dll)
  *
- * Copyright 2002 Mike McCormack for CodeWeavers
+ * Copyright 2002,2003 Mike McCormack for CodeWeavers
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -25,6 +25,7 @@
 #include "windef.h"
 #include "winbase.h"
 #include "winreg.h"
+#include "winnls.h"
 #include "shlwapi.h"
 #include "wine/debug.h"
 #include "msi.h"
@@ -135,21 +136,26 @@
 {
     HRESULT r = ERROR_FUNCTION_FAILED;
     LPWSTR szwDBPath = NULL, szwPersist = NULL;
+    UINT len;
 
     TRACE("%s %s %p\n", debugstr_a(szDBPath), debugstr_a(szPersist), phDB);
 
     if( szDBPath )
     {
-        szwDBPath = HEAP_strdupAtoW( GetProcessHeap(), 0, szDBPath );
+        len = MultiByteToWideChar( CP_ACP, 0, szDBPath, -1, NULL, 0 );
+        szwDBPath = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
         if( !szwDBPath )
             goto end;
+        MultiByteToWideChar( CP_ACP, 0, szDBPath, -1, szwDBPath, len );
     }
 
     if( szPersist )
     {
-        szwPersist = HEAP_strdupAtoW( GetProcessHeap(), 0, szPersist );
+        len = MultiByteToWideChar( CP_ACP, 0, szPersist, -1, NULL, 0 );
+        szwPersist = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
         if( !szwPersist )
             goto end;
+        MultiByteToWideChar( CP_ACP, 0, szPersist, -1, szwPersist, len );
     }
 
     r = MsiOpenDatabaseW( szwDBPath, szwPersist, phDB );
@@ -287,16 +293,20 @@
 
     if( szPackagePath )
     {
-        szwPath = HEAP_strdupAtoW(GetProcessHeap(),0,szPackagePath);
-        if( szwPath == NULL )
-            goto end; 
+        UINT len = MultiByteToWideChar( CP_ACP, 0, szPackagePath, -1, NULL, 0 );
+        szwPath = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
+        if( !szwPath )
+            goto end;
+        MultiByteToWideChar( CP_ACP, 0, szPackagePath, -1, szwPath, len );
     }
 
     if( szCommandLine )
     {
-        szwCommand = HEAP_strdupAtoW(GetProcessHeap(),0,szCommandLine);
-        if( szwCommand == NULL )
-            goto end; 
+        UINT len = MultiByteToWideChar( CP_ACP, 0, szCommandLine, -1, NULL, 0 );
+        szwCommand = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
+        if( !szwCommand )
+            goto end;
+        MultiByteToWideChar( CP_ACP, 0, szCommandLine, -1, szwCommand, len );
     }
  
     r = MsiInstallProductW( szwPath, szwCommand );
@@ -478,13 +488,15 @@
 
     if( szProduct )
     {
-        szwProduct = HEAP_strdupAtoW(GetProcessHeap(),0,szProduct);
-        if( !szwProduct )
+        UINT len = MultiByteToWideChar( CP_ACP, 0, szProduct, -1, NULL, 0 );
+        szwProduct = HeapAlloc( GetProcessHeap(), 0, len * sizeof (WCHAR) );
+        if( szwProduct )
+            MultiByteToWideChar( CP_ACP, 0, szProduct, -1, szwProduct, len );
+        else
             return ERROR_FUNCTION_FAILED;
     }
 
-    r = MsiEnumFeaturesW(szProduct?szwProduct:NULL, 
-                         index, szwFeature, szwParent);
+    r = MsiEnumFeaturesW(szwProduct, index, szwFeature, szwParent);
     if( r == ERROR_SUCCESS )
     {
         WideCharToMultiByte(CP_ACP, 0, szwFeature, -1,
@@ -591,8 +603,11 @@
 
     if( szComponent )
     {
-        szwComponent = HEAP_strdupAtoW(GetProcessHeap(),0,szComponent);
-        if( !szwComponent )
+        UINT len = MultiByteToWideChar( CP_ACP, 0, szComponent, -1, NULL, 0 );
+        szwComponent = HeapAlloc( GetProcessHeap(), 0, len * sizeof (WCHAR) );
+        if( szwComponent )
+            MultiByteToWideChar( CP_ACP, 0, szComponent, -1, szwComponent, len );
+        else
             return ERROR_FUNCTION_FAILED;
     }
 
Index: dlls/msi/msipriv.h
===================================================================
RCS file: /home/wine/wine/dlls/msi/msipriv.h,v
retrieving revision 1.3
diff -u -r1.3 msipriv.h
--- dlls/msi/msipriv.h	8 Sep 2003 19:38:46 -0000	1.3
+++ dlls/msi/msipriv.h	26 Sep 2003 19:05:47 -0000
@@ -173,18 +173,4 @@
 
 UINT VIEW_find_column( MSIVIEW *view, LPWSTR name, UINT *n );
 
-/* FIXME! should get rid of that */
-#include "winnls.h"
-inline static LPWSTR HEAP_strdupAtoW( HANDLE heap, DWORD flags, LPCSTR str )
-{
-    LPWSTR ret;
-    INT len;
-
-    if (!str) return NULL;
-    len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
-    ret = HeapAlloc( heap, flags, len * sizeof(WCHAR) );
-    if (ret) MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len );
-    return ret;
-}
-
 #endif /* __WINE_MSI_PRIVATE__ */
Index: dlls/msi/msiquery.c
===================================================================
RCS file: /home/wine/wine/dlls/msi/msiquery.c,v
retrieving revision 1.3
diff -u -r1.3 msiquery.c
--- dlls/msi/msiquery.c	8 Sep 2003 19:38:46 -0000	1.3
+++ dlls/msi/msiquery.c	26 Sep 2003 19:05:47 -0000
@@ -97,15 +97,17 @@
               LPCSTR szQuery, MSIHANDLE *phView)
 {
     UINT r;
-    LPCWSTR szwQuery;
+    LPWSTR szwQuery;
 
     TRACE("%ld %s %p\n", hdb, debugstr_a(szQuery), phView);
 
     if( szQuery )
     {
-        szwQuery = HEAP_strdupAtoW( GetProcessHeap(), 0, szQuery );
+        UINT len = MultiByteToWideChar( CP_ACP, 0, szQuery, -1, NULL, 0 );
+        szwQuery = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
         if( !szwQuery )
             return ERROR_FUNCTION_FAILED;
+        MultiByteToWideChar( CP_ACP, 0, szQuery, -1, szwQuery, len );
     }
     else
         szwQuery = NULL;
Index: dlls/msi/suminfo.c
===================================================================
RCS file: /home/wine/wine/dlls/msi/suminfo.c,v
retrieving revision 1.3
diff -u -r1.3 suminfo.c
--- dlls/msi/suminfo.c	8 Sep 2003 19:38:46 -0000	1.3
+++ dlls/msi/suminfo.c	26 Sep 2003 19:05:47 -0000
@@ -25,6 +25,7 @@
 #include "windef.h"
 #include "winbase.h"
 #include "winreg.h"
+#include "winnls.h"
 #include "shlwapi.h"
 #include "wine/debug.h"
 #include "msi.h"
@@ -54,9 +55,11 @@
 
     if( szDatabase )
     {
-        szwDatabase = HEAP_strdupAtoW( GetProcessHeap(), 0, szDatabase );
+        UINT len = MultiByteToWideChar( CP_ACP, 0, szDatabase, -1, NULL, 0 );
+        szwDatabase = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
         if( !szwDatabase )
             return ERROR_FUNCTION_FAILED;
+        MultiByteToWideChar( CP_ACP, 0, szDatabase, -1, szwDatabase, len );
     }
 
     ret = MsiGetSummaryInformationW(hDatabase, szwDatabase, uiUpdateCount, phSummaryInfo);


More information about the wine-patches mailing list