diff --git a/dlls/msi/action.c b/dlls/msi/action.c index 34cc0e9a275..99dcedc180a 100644 --- a/dlls/msi/action.c +++ b/dlls/msi/action.c @@ -508,8 +508,8 @@ int track_tempfile(MSIPACKAGE *package, LPCWSTR name, LPCWSTR path) memset(&package->files[index],0,sizeof(MSIFILE)); - package->files[index].File = dupstrW(name); - package->files[index].TargetPath = dupstrW(path); + package->files[index].File = strdupW(name); + package->files[index].TargetPath = strdupW(path); package->files[index].Temporary = TRUE; TRACE("Tracking tempfile (%s)\n",debugstr_w(package->files[index].File)); @@ -677,7 +677,7 @@ static void ui_actiondata(MSIPACKAGE *package, LPCWSTR action, MSIRECORD * recor package->ActionFormat = load_dynamic_stringW(row,3); HeapFree(GetProcessHeap(),0,package->LastAction); - package->LastAction = dupstrW(action); + package->LastAction = strdupW(action); msiobj_release(&row->hdr); MSI_ViewClose(view); @@ -875,8 +875,8 @@ UINT ACTION_DoTopLevelINSTALL(MSIPACKAGE *package, LPCWSTR szPackagePath, { LPWSTR p, check, path; - package->PackagePath = dupstrW(szPackagePath); - path = dupstrW(szPackagePath); + package->PackagePath = strdupW(szPackagePath); + path = strdupW(szPackagePath); p = strrchrW(path,'\\'); if (p) { @@ -1921,7 +1921,7 @@ static INT load_folder(MSIPACKAGE *package, const WCHAR* dir) memset(&package->folders[index],0,sizeof(MSIFOLDER)); - package->folders[index].Directory = dupstrW(dir); + package->folders[index].Directory = strdupW(dir); rc = MSI_OpenQuery(package->db, &view, Query, dir); if (rc != ERROR_SUCCESS) @@ -1980,13 +1980,13 @@ static INT load_folder(MSIPACKAGE *package, const WCHAR* dir) { TRACE(" TargetDefault = %s\n",debugstr_w(targetdir)); HeapFree(GetProcessHeap(),0, package->folders[index].TargetDefault); - package->folders[index].TargetDefault = dupstrW(targetdir); + package->folders[index].TargetDefault = strdupW(targetdir); } if (srcdir) - package->folders[index].SourceDefault = dupstrW(srcdir); + package->folders[index].SourceDefault = strdupW(srcdir); else if (targetdir) - package->folders[index].SourceDefault = dupstrW(targetdir); + package->folders[index].SourceDefault = strdupW(targetdir); HeapFree(GetProcessHeap(), 0, ptargetdir); parent = load_dynamic_stringW(row,2); @@ -2084,13 +2084,13 @@ LPWSTR resolve_folder(MSIPACKAGE *package, LPCWSTR name, BOOL source, if (!source && package->folders[i].ResolvedTarget) { - path = dupstrW(package->folders[i].ResolvedTarget); + path = strdupW(package->folders[i].ResolvedTarget); TRACE(" already resolved to %s\n",debugstr_w(path)); return path; } else if (source && package->folders[i].ResolvedSource) { - path = dupstrW(package->folders[i].ResolvedSource); + path = strdupW(package->folders[i].ResolvedSource); return path; } else if (!source && package->folders[i].Property) @@ -2114,7 +2114,7 @@ LPWSTR resolve_folder(MSIPACKAGE *package, LPCWSTR name, BOOL source, { TRACE(" TargetDefault = %s\n",debugstr_w(package->folders[i].TargetDefault)); path = build_directory_name(3, p, package->folders[i].TargetDefault, NULL); - package->folders[i].ResolvedTarget = dupstrW(path); + package->folders[i].ResolvedTarget = strdupW(path); TRACE(" resolved into %s\n",debugstr_w(path)); if (set_prop) MSI_SetPropertyW(package,name,path); @@ -2122,7 +2122,7 @@ LPWSTR resolve_folder(MSIPACKAGE *package, LPCWSTR name, BOOL source, else { path = build_directory_name(3, p, package->folders[i].SourceDefault, NULL); - package->folders[i].ResolvedSource = dupstrW(path); + package->folders[i].ResolvedSource = strdupW(path); } HeapFree(GetProcessHeap(),0,p); } @@ -3119,7 +3119,7 @@ inline static UINT get_file_target(MSIPACKAGE *package, LPCWSTR file_key, { if (package->files[index].State >= 2) { - *file_source = dupstrW(package->files[index].TargetPath); + *file_source = strdupW(package->files[index].TargetPath); return ERROR_SUCCESS; } else @@ -3231,7 +3231,7 @@ static UINT ACTION_DuplicateFiles(MSIPACKAGE *package) if (MSI_RecordIsNull(row,5)) { LPWSTR p; - dest_path = dupstrW(file_source); + dest_path = strdupW(file_source); p = strrchrW(dest_path,'\\'); if (p) *p=0; @@ -3759,7 +3759,7 @@ static LPWSTR resolve_keypath( MSIPACKAGE* package, INT if (j>=0) { - LPWSTR p = dupstrW(package->files[j].TargetPath); + LPWSTR p = strdupW(package->files[j].TargetPath); return p; } } @@ -4882,7 +4882,7 @@ static UINT ACTION_CreateShortcuts(MSIPACKAGE *package) { LPWSTR keypath; FIXME("poorly handled shortcut format, advertised shortcut\n"); - keypath = dupstrW(package->components[index].FullKeypath); + keypath = strdupW(package->components[index].FullKeypath); IShellLinkW_SetPath(sl,keypath); HeapFree(GetProcessHeap(),0,keypath); } diff --git a/dlls/msi/action.h b/dlls/msi/action.h index 1ac1430c32e..af718bee464 100644 --- a/dlls/msi/action.h +++ b/dlls/msi/action.h @@ -116,39 +116,3 @@ int get_loaded_component(MSIPACKAGE* package, LPCWSTR Component ); int get_loaded_feature(MSIPACKAGE* package, LPCWSTR Feature ); int get_loaded_file(MSIPACKAGE* package, LPCWSTR file); int track_tempfile(MSIPACKAGE *package, LPCWSTR name, LPCWSTR path); - - - -inline static char *strdupWtoA( const WCHAR *str ) -{ - char *ret = NULL; - if (str) - { - DWORD len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL -); - if ((ret = HeapAlloc( GetProcessHeap(), 0, len ))) - WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL ); - } - return ret; -} - -inline static WCHAR *strdupAtoW( const char *str ) -{ - WCHAR *ret = NULL; - if (str) - { - DWORD len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 ); - if ((ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) - MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len ); - } - return ret; -} - -inline static LPWSTR dupstrW(LPCWSTR src) -{ - LPWSTR dest; - if (!src) return NULL; - dest = HeapAlloc(GetProcessHeap(), 0, (strlenW(src)+1)*sizeof(WCHAR)); - strcpyW(dest, src); - return dest; -} diff --git a/dlls/msi/custom.c b/dlls/msi/custom.c index 7a7f1aa7636..2f0e8c2e8d0 100644 --- a/dlls/msi/custom.c +++ b/dlls/msi/custom.c @@ -145,7 +145,7 @@ UINT ACTION_CustomAction(MSIPACKAGE *package,LPCWSTR action, BOOL execute) else newbuf = HeapAlloc(GetProcessHeap(),0, sizeof(LPWSTR)); - newbuf[count] = dupstrW(action); + newbuf[count] = strdupW(action); package->CommitAction = newbuf; } else @@ -160,7 +160,7 @@ UINT ACTION_CustomAction(MSIPACKAGE *package,LPCWSTR action, BOOL execute) else newbuf = HeapAlloc(GetProcessHeap(),0, sizeof(LPWSTR)); - newbuf[count] = dupstrW(action); + newbuf[count] = strdupW(action); package->DeferredAction = newbuf; } @@ -326,7 +326,7 @@ static void file_running_action(MSIPACKAGE* package, HANDLE Handle, newbuf[count].handle = Handle; newbuf[count].process = process; - newbuf[count].name = dupstrW(name); + newbuf[count].name = strdupW(name); package->RunningAction = newbuf; } @@ -508,8 +508,8 @@ static UINT HANDLE_CustomType1(MSIPACKAGE *package, LPCWSTR source, info = HeapAlloc( GetProcessHeap(), 0, sizeof(*info) ); msiobj_addref( &package->hdr ); info->package = package; - info->target = dupstrW(target); - info->source = dupstrW(tmp_file); + info->target = strdupW(target); + info->source = strdupW(tmp_file); ThreadHandle = CreateThread(NULL,0,DllThread,(LPVOID)info,0,&ThreadId); diff --git a/dlls/msi/dialog.c b/dlls/msi/dialog.c index ccd01a43c1c..f0cc54452cf 100644 --- a/dlls/msi/dialog.c +++ b/dlls/msi/dialog.c @@ -309,7 +309,7 @@ static UINT msi_dialog_checkbox_control( msi_dialog *dialog, MSIRECORD *rec ) control->handler = msi_dialog_checkbox_handler; prop = MSI_RecordGetString( rec, 9 ); if( prop ) - control->property = dupstrW( prop ); + control->property = strdupW( prop ); msi_dialog_checkbox_sync_state( dialog, control ); return ERROR_SUCCESS; @@ -364,7 +364,7 @@ static UINT msi_dialog_edit_control( msi_dialog *dialog, MSIRECORD *rec ) control->handler = msi_dialog_edit_handler; prop = MSI_RecordGetString( rec, 9 ); if( prop ) - control->property = dupstrW( prop ); + control->property = strdupW( prop ); val = load_dynamic_property( dialog->package, control->property, NULL ); SetWindowTextW( control->hwnd, val ); HeapFree( GetProcessHeap(), 0, val ); @@ -433,7 +433,7 @@ static UINT msi_dialog_create_radiobutton( MSIRECORD *rec, LPVOID param ) prop = MSI_RecordGetString( rec, 1 ); if( prop ) - control->property = dupstrW( prop ); + control->property = strdupW( prop ); return ERROR_SUCCESS; } @@ -467,7 +467,7 @@ static UINT msi_dialog_radiogroup_control( msi_dialog *dialog, MSIRECORD *rec ) } if( prop ) - control->property = dupstrW( prop ); + control->property = strdupW( prop ); /* query the Radio Button table for all control in this group */ r = MSI_OpenQuery( package->db, &view, query, prop ); diff --git a/dlls/msi/format.c b/dlls/msi/format.c index 3e769da84fe..b40fe5f738e 100644 --- a/dlls/msi/format.c +++ b/dlls/msi/format.c @@ -114,7 +114,7 @@ static LPWSTR deformat_file(MSIPACKAGE* package, LPCWSTR key, DWORD* sz) index = get_loaded_file(package,key); if (index >=0) { - value = dupstrW(package->files[index].TargetPath); + value = strdupW(package->files[index].TargetPath); *sz = (strlenW(value)) * sizeof(WCHAR); } diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h index 76ce9ed976d..cbb71e1b37f 100644 --- a/dlls/msi/msipriv.h +++ b/dlls/msi/msipriv.h @@ -29,6 +29,7 @@ #include "msiquery.h" #include "objbase.h" #include "objidl.h" +#include "wine/unicode.h" #define MSI_DATASIZEMASK 0x00ff #define MSITYPE_VALID 0x0100 @@ -386,4 +387,38 @@ extern DWORD gUIFilter; extern LPVOID gUIContext; extern WCHAR gszLogFile[MAX_PATH]; +inline static char *strdupWtoA( LPCWSTR str ) +{ + LPSTR ret = NULL; + if (str) + { + DWORD len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL +); + if ((ret = HeapAlloc( GetProcessHeap(), 0, len ))) + WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL ); + } + return ret; +} + +inline static LPWSTR strdupAtoW( LPCSTR str ) +{ + LPWSTR ret = NULL; + if (str) + { + DWORD len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 ); + if ((ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) + MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len ); + } + return ret; +} + +inline static LPWSTR strdupW( LPCWSTR src ) +{ + LPWSTR dest; + if (!src) return NULL; + dest = HeapAlloc(GetProcessHeap(), 0, (strlenW(src)+1)*sizeof(WCHAR)); + strcpyW(dest, src); + return dest; +} + #endif /* __WINE_MSI_PRIVATE__ */ diff --git a/dlls/msi/table.c b/dlls/msi/table.c index dbfad627013..831ae81445e 100644 --- a/dlls/msi/table.c +++ b/dlls/msi/table.c @@ -834,15 +834,6 @@ err: return ret; } -static LPWSTR strdupW( LPCWSTR str ) -{ - UINT len = lstrlenW( str ) + 1; - LPWSTR ret = HeapAlloc( GetProcessHeap(), 0, len*sizeof (WCHAR) ); - if( ret ) - lstrcpyW( ret, str ); - return ret; -} - /* information for default tables */ static const WCHAR szTables[] = { '_','T','a','b','l','e','s',0 }; static const WCHAR szTable[] = { 'T','a','b','l','e',0 };