Got rid of HEAP_strdupW.
diff --git a/controls/menu.c b/controls/menu.c index 7456020..0bc988b 100644 --- a/controls/menu.c +++ b/controls/menu.c
@@ -25,7 +25,6 @@ #include "wine/unicode.h" #include "wine/port.h" #include "win.h" -#include "heap.h" #include "controls.h" #include "nonclient.h" #include "user.h" @@ -1736,7 +1735,9 @@ flags |= MF_HELP; str++; } - if (!(text = HEAP_strdupW( GetProcessHeap(), 0, str ))) return FALSE; + if (!(text = HeapAlloc( GetProcessHeap(), 0, (strlenW(str)+1) * sizeof(WCHAR) ))) + return FALSE; + strcpyW( text, str ); item->text = text; } } @@ -3531,13 +3532,18 @@ BOOL WINAPI InsertMenuA( HMENU hMenu, UINT pos, UINT flags, UINT id, LPCSTR str ) { - BOOL ret; + BOOL ret = FALSE; if (IS_STRING_ITEM(flags) && str) { - LPWSTR newstr = HEAP_strdupAtoW( GetProcessHeap(), 0, str ); - ret = InsertMenuW( hMenu, pos, flags, id, newstr ); - HeapFree( GetProcessHeap(), 0, newstr ); + INT len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 ); + LPWSTR newstr = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ); + if (newstr) + { + MultiByteToWideChar( CP_ACP, 0, str, -1, newstr, len ); + ret = InsertMenuW( hMenu, pos, flags, id, newstr ); + HeapFree( GetProcessHeap(), 0, newstr ); + } return ret; } else return InsertMenuW( hMenu, pos, flags, id, (LPCWSTR)str ); @@ -3684,13 +3690,18 @@ BOOL WINAPI ModifyMenuA( HMENU hMenu, UINT pos, UINT flags, UINT id, LPCSTR str ) { - BOOL ret; + BOOL ret = FALSE; if (IS_STRING_ITEM(flags) && str) { - LPWSTR newstr = HEAP_strdupAtoW( GetProcessHeap(), 0, str ); - ret = ModifyMenuW( hMenu, pos, flags, id, newstr ); - HeapFree( GetProcessHeap(), 0, newstr ); + INT len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 ); + LPWSTR newstr = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ); + if (newstr) + { + MultiByteToWideChar( CP_ACP, 0, str, -1, newstr, len ); + ret = ModifyMenuW( hMenu, pos, flags, id, newstr ); + HeapFree( GetProcessHeap(), 0, newstr ); + } return ret; } else return ModifyMenuW( hMenu, pos, flags, id, (LPCWSTR)str ); @@ -4366,6 +4377,30 @@ lpmii, TRUE); } + +/* set a menu item text from a ASCII or Unicode string */ +inline static void set_menu_item_text( MENUITEM *menu, LPCWSTR text, BOOL unicode ) +{ + if (!text) + { + menu->text = NULL; + menu->fType |= MF_SEPARATOR; + } + else if (unicode) + { + if ((menu->text = HeapAlloc( GetProcessHeap(), 0, (strlenW(text)+1) * sizeof(WCHAR) ))) + strcpyW( menu->text, text ); + } + else + { + LPCSTR str = (LPCSTR)text; + int len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 ); + if ((menu->text = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) + MultiByteToWideChar( CP_ACP, 0, str, -1, menu->text, len ); + } +} + + /********************************************************************** * SetMenuItemInfo_common */ @@ -4391,16 +4426,8 @@ menu->text = lpmii->dwTypeData; - if (IS_STRING_ITEM(menu->fType)) { - if (menu->text) { - if (unicode) - menu->text = HEAP_strdupW(GetProcessHeap(), 0, lpmii->dwTypeData); - else - menu->text = HEAP_strdupAtoW(GetProcessHeap(), 0, (LPSTR)lpmii->dwTypeData); - } - else - menu->fType |= MF_SEPARATOR; - } + if (IS_STRING_ITEM(menu->fType)) + set_menu_item_text( menu, lpmii->dwTypeData, unicode ); } if (lpmii->fMask & MIIM_FTYPE ) { @@ -4419,14 +4446,7 @@ /* free the string when used */ if ( IS_STRING_ITEM(menu->fType) && menu->text) { HeapFree(GetProcessHeap(), 0, menu->text); - if (lpmii->dwTypeData) { - if (unicode) - menu->text = HEAP_strdupW(GetProcessHeap(), 0, lpmii->dwTypeData); - else - menu->text = HEAP_strdupAtoW(GetProcessHeap(), 0, (LPSTR) lpmii->dwTypeData); - } - else - menu->fType |= MF_SEPARATOR; + set_menu_item_text( menu, lpmii->dwTypeData, unicode ); } }
diff --git a/dlls/shell32/shell32_main.c b/dlls/shell32/shell32_main.c index f2d32fb..dd6e84a 100644 --- a/dlls/shell32/shell32_main.c +++ b/dlls/shell32/shell32_main.c
@@ -43,8 +43,11 @@ TRACE("\n"); /* to get writeable copy */ - cmdline = HEAP_strdupW( GetProcessHeap(), 0, lpCmdline); - s=cmdline;i=0; + if (!(cmdline = HeapAlloc( GetProcessHeap(), 0, (strlenW(lpCmdline)+1) * sizeof(WCHAR) ))) + return NULL; + strcpyW( cmdline, lpCmdline ); + s=cmdline; + i=0; while (*s) { /* space */ if (*s==0x0020) @@ -60,21 +63,19 @@ s=t=cmdline; i=0; while (*s) - { if (*s==0x0020) - { *s=0; - argv[i++]=HEAP_strdupW( GetProcessHeap(), 0, t ); - *s=0x0020; - while (*s && *s==0x0020) - s++; - t=s; - continue; - } - s++; + { + if (*s==0x0020) + { + argv[i++]=t; + while (*s==0x0020) *s++ = 0; + t=s; + continue; + } + s++; } if (*t) - argv[i++]=(LPWSTR)HEAP_strdupW( GetProcessHeap(), 0, t ); + argv[i++]=t; - HeapFree( GetProcessHeap(), 0, cmdline ); argv[i]=NULL; *numargs=i; return argv;
diff --git a/include/heap.h b/include/heap.h index 0840e10..bfab67b 100644 --- a/include/heap.h +++ b/include/heap.h
@@ -43,14 +43,6 @@ return p; } -inline static LPWSTR HEAP_strdupW( HANDLE heap, DWORD flags, LPCWSTR str ) -{ - INT len = strlenW(str) + 1; - LPWSTR p = HeapAlloc( heap, flags, len * sizeof(WCHAR) ); - if (p) memcpy( p, str, len * sizeof(WCHAR) ); - return p; -} - inline static LPWSTR HEAP_strdupAtoW( HANDLE heap, DWORD flags, LPCSTR str ) { LPWSTR ret;
diff --git a/windows/mdi.c b/windows/mdi.c index cfad061..36a47cc 100644 --- a/windows/mdi.c +++ b/windows/mdi.c
@@ -1183,7 +1183,8 @@ if (lpTitle) { if (ci->frameTitle) HeapFree( GetProcessHeap(), 0, ci->frameTitle ); - ci->frameTitle = HEAP_strdupW( GetProcessHeap(), 0, lpTitle ); + if ((ci->frameTitle = HeapAlloc( GetProcessHeap(), 0, (strlenW(lpTitle)+1)*sizeof(WCHAR)))) + strcpyW( ci->frameTitle, lpTitle ); } if (ci->frameTitle)