windows/winproc.c: Get rid of HEAP_strdupWtoA calls

Dmitry Timoshkov dmitry at baikal.ru
Sat Jan 8 05:38:26 CST 2005


"Jacek Caban" <jack at itma.pwr.wroc.pl> wrote:

> @@ -1010,9 +1009,15 @@ static INT WINPROC_MapMsg32WTo32A( HWND 
>      case LB_DIR:
>      case LB_ADDFILE:
>      case EM_REPLACESEL:
> -        if(!*plparam) return 0;
> -        *plparam = (LPARAM)HEAP_strdupWtoA( GetProcessHeap(), 0, (LPCWSTR)*plparam );
> -        return (*plparam ? 1 : -1);
> +        if(*plparam) {
> +            LPSTR buf;
> +            int len = WideCharToMultiByte(CP_ACP, 0, (LPWSTR)*plparam, -1, NULL, 0, 0, 0);
> +            buf = HeapAlloc(GetProcessHeap(), 0, len*sizeof(CHAR));
> +            WideCharToMultiByte(CP_ACP, 0, (LPWSTR)*plparam, -1, buf, len, 0, 0);
> +            *plparam = (LPARAM)buf;
> +            return 1;
> +        }
> +        return 0;

It would be helpful to keep the test in the case of a buffer allocation failure
here and everywhere else (and perhaps add the missing tests).

-- 
Dmitry.




More information about the wine-devel mailing list