Removed some of the calls to HEAP_strdup* functions.

This commit is contained in:
Alexandre Julliard 2002-01-01 00:24:30 +00:00
parent 424a080c30
commit 193cf50a09
22 changed files with 226 additions and 194 deletions

View File

@ -14,15 +14,15 @@
#include <string.h>
#include <stdlib.h>
#include "winnls.h"
#include "winerror.h"
#include "debugtools.h"
#include "heap.h"
#include "ddraw.h"
#include "d3d.h"
/* This for all the enumeration and creation of D3D-related objects */
#include "ddraw_private.h"
#include "debugtools.h"
#define MAX_DDRAW_DRIVERS 3
static const ddraw_driver* DDRAW_drivers[MAX_DDRAW_DRIVERS];
@ -93,14 +93,21 @@ static BOOL CALLBACK DirectDrawEnumerateExProcW(
GUID *lpGUID, LPSTR lpDriverDescription, LPSTR lpDriverName,
LPVOID lpContext, HMONITOR hm)
{
INT len;
BOOL bResult;
LPWSTR lpDriverDescriptionW, lpDriverNameW;
DirectDrawEnumerateProcData *pEPD = (DirectDrawEnumerateProcData*)lpContext;
LPWSTR lpDriverDescriptionW =
HEAP_strdupAtoW(GetProcessHeap(), 0, lpDriverDescription);
LPWSTR lpDriverNameW =
HEAP_strdupAtoW(GetProcessHeap(), 0, lpDriverName);
BOOL bResult = (*(LPDDENUMCALLBACKEXW *) pEPD->lpCallback)(
lpGUID, lpDriverDescriptionW, lpDriverNameW, pEPD->lpContext, hm);
len = MultiByteToWideChar( CP_ACP, 0, lpDriverDescription, -1, NULL, 0 );
lpDriverDescriptionW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
MultiByteToWideChar( CP_ACP, 0, lpDriverDescription, -1, lpDriverDescriptionW, len );
len = MultiByteToWideChar( CP_ACP, 0, lpDriverName, -1, NULL, 0 );
lpDriverNameW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
MultiByteToWideChar( CP_ACP, 0, lpDriverName, -1, lpDriverNameW, len );
bResult = (*(LPDDENUMCALLBACKEXW *) pEPD->lpCallback)(lpGUID, lpDriverDescriptionW,
lpDriverNameW, pEPD->lpContext, hm);
HeapFree(GetProcessHeap(), 0, lpDriverDescriptionW);
HeapFree(GetProcessHeap(), 0, lpDriverNameW);

View File

@ -9,8 +9,8 @@
#include <unistd.h>
#include "winbase.h"
#include "winnls.h"
#include "winnetwk.h"
#include "heap.h"
#include "debugtools.h"
DEFAULT_DEBUG_CHANNEL(mpr);
@ -369,9 +369,12 @@ DWORD WINAPI WNetGetConnectionW( LPCWSTR lpLocalName,
LPWSTR lpRemoteName, LPDWORD lpBufferSize )
{
CHAR buf[200];
DWORD x = sizeof(buf);
LPSTR lnA = HEAP_strdupWtoA( GetProcessHeap(), 0, lpLocalName );
DWORD ret = WNetGetConnectionA( lnA, buf, &x );
DWORD ret, x = sizeof(buf);
INT len = WideCharToMultiByte( CP_ACP, 0, lpLocalName, -1, NULL, 0, NULL, NULL );
LPSTR lnA = HeapAlloc( GetProcessHeap(), 0, len );
WideCharToMultiByte( CP_ACP, 0, lpLocalName, -1, lnA, len, NULL, NULL );
ret = WNetGetConnectionA( lnA, buf, &x );
HeapFree( GetProcessHeap(), 0, lnA );
if (ret == WN_SUCCESS)
{

View File

@ -24,7 +24,7 @@
#include "winreg.h"
#include "wownt32.h"
#include "wtypes.h"
#include "wine/unicode.h"
#include "wine/obj_base.h"
#include "wine/obj_clientserver.h"
#include "wine/obj_misc.h"
@ -33,7 +33,6 @@
#include "wine/winbase16.h"
#include "compobj_private.h"
#include "ifs.h"
#include "heap.h"
#include "debugtools.h"
@ -538,12 +537,14 @@ HRESULT WINAPI CoCreateGuid(
*/
HRESULT WINAPI CLSIDFromString(
LPCOLESTR idstr, /* [in] string representation of GUID */
CLSID *id /* [out] GUID represented by above string */
) {
LPOLESTR16 xid = HEAP_strdupWtoA(GetProcessHeap(),0,idstr);
HRESULT ret = CLSIDFromString16(xid,id);
CLSID *id ) /* [out] GUID represented by above string */
{
char xid[40];
HRESULT ret;
HeapFree(GetProcessHeap(),0,xid);
if (!WideCharToMultiByte( CP_ACP, 0, idstr, -1, xid, sizeof(xid), NULL, NULL ))
return CO_E_CLASSSTRING;
ret = CLSIDFromString16(xid,id);
if(ret != S_OK) { /* It appears a ProgID is also valid */
ret = CLSIDFromProgID(idstr, id);
}
@ -774,13 +775,30 @@ HRESULT WINAPI CLSIDFromProgID16(
*/
HRESULT WINAPI CLSIDFromProgID(
LPCOLESTR progid, /* [in] program id as found in registry */
LPCLSID riid /* [out] associated CLSID */
) {
LPOLESTR16 pid = HEAP_strdupWtoA(GetProcessHeap(),0,progid);
HRESULT ret = CLSIDFromProgID16(pid,riid);
LPCLSID riid ) /* [out] associated CLSID */
{
static const WCHAR clsidW[] = { '\\','C','L','S','I','D',0 };
char buf2[80];
DWORD buf2len = sizeof(buf2);
HKEY xhkey;
HeapFree(GetProcessHeap(),0,pid);
return ret;
WCHAR *buf = HeapAlloc( GetProcessHeap(),0,(strlenW(progid)+8) * sizeof(WCHAR) );
strcpyW( buf, progid );
strcatW( buf, clsidW );
if (RegOpenKeyW(HKEY_CLASSES_ROOT,buf,&xhkey))
{
HeapFree(GetProcessHeap(),0,buf);
return CO_E_CLASSSTRING;
}
HeapFree(GetProcessHeap(),0,buf);
if (RegQueryValueA(xhkey,NULL,buf2,&buf2len))
{
RegCloseKey(xhkey);
return CO_E_CLASSSTRING;
}
RegCloseKey(xhkey);
return CLSIDFromString16(buf2,riid);
}

View File

@ -10,10 +10,10 @@
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "debugtools.h"
#include "winnls.h"
#include "ole2.h"
#include "olectl.h"
#include "heap.h"
#include "debugtools.h"
DEFAULT_DEBUG_CHANNEL(ole);
@ -233,9 +233,12 @@ ULONG WINAPI LHashValOfNameSys( SYSKIND skind, LCID lcid, LPCOLESTR str)
{
LPSTR strA;
ULONG res;
INT len;
if (!str) return 0;
strA = HEAP_strdupWtoA(GetProcessHeap(), 0, str);
len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL );
strA = HeapAlloc( GetProcessHeap(), 0, len );
WideCharToMultiByte( CP_ACP, 0, str, -1, strA, len, NULL, NULL );
res = LHashValOfNameSysA(skind, lcid, strA);
HeapFree(GetProcessHeap(), 0, strA);
return res;

View File

@ -20,7 +20,6 @@
#include "ole2.h"
#include "olectl.h"
#include "debugtools.h"
#include "heap.h"
#include "connpt.h" /* for CreateConnectionPoint */
DEFAULT_DEBUG_CHANNEL(ole);
@ -1335,6 +1334,7 @@ static HRESULT WINAPI OLEFontImpl_Load(
BYTE bVersion;
BYTE bAttributes;
BYTE bStringSize;
INT len;
_ICOM_THIS_From_IPersistStream(OLEFontImpl, iface);
@ -1393,7 +1393,6 @@ static HRESULT WINAPI OLEFontImpl_Load(
if (cbRead!=1)
return E_FAIL;
memset(readBuffer, 0, 0x100);
IStream_Read(pLoadStream, readBuffer, bStringSize, &cbRead);
if (cbRead!=bStringSize)
@ -1402,9 +1401,10 @@ static HRESULT WINAPI OLEFontImpl_Load(
if (this->description.lpstrName!=0)
HeapFree(GetProcessHeap(), 0, this->description.lpstrName);
this->description.lpstrName = HEAP_strdupAtoW(GetProcessHeap(),
HEAP_ZERO_MEMORY,
readBuffer);
len = MultiByteToWideChar( CP_ACP, 0, readBuffer, bStringSize, NULL, 0 );
this->description.lpstrName = HeapAlloc( GetProcessHeap(), 0, (len+1) * sizeof(WCHAR) );
MultiByteToWideChar( CP_ACP, 0, readBuffer, bStringSize, this->description.lpstrName, len );
this->description.lpstrName[len] = 0;
return S_OK;
}
@ -1482,7 +1482,8 @@ static HRESULT WINAPI OLEFontImpl_Save(
* FontName
*/
if (this->description.lpstrName!=0)
bStringSize = lstrlenW(this->description.lpstrName);
bStringSize = WideCharToMultiByte( CP_ACP, 0, this->description.lpstrName,
strlenW(this->description.lpstrName), NULL, 0, NULL, NULL );
else
bStringSize = 0;
@ -1493,15 +1494,12 @@ static HRESULT WINAPI OLEFontImpl_Save(
if (bStringSize!=0)
{
writeBuffer = HEAP_strdupWtoA(GetProcessHeap(),
HEAP_ZERO_MEMORY,
this->description.lpstrName);
if (writeBuffer==0)
return E_OUTOFMEMORY;
if (!(writeBuffer = HeapAlloc( GetProcessHeap(), 0, bStringSize ))) return E_OUTOFMEMORY;
WideCharToMultiByte( CP_ACP, 0, this->description.lpstrName,
strlenW(this->description.lpstrName),
writeBuffer, bStringSize, NULL, NULL );
IStream_Write(pOutStream, writeBuffer, bStringSize, &cbWritten);
HeapFree(GetProcessHeap(), 0, writeBuffer);
if (cbWritten!=bStringSize)

View File

@ -20,7 +20,6 @@
#include "winuser.h"
#include "wine/winbase16.h"
#include "cursoricon.h"
#include "heap.h"
#include "debugtools.h"
DEFAULT_DEBUG_CHANNEL(icon);
@ -572,8 +571,10 @@ HRESULT WINAPI PrivateExtractIconsA (
DWORD y ) /* [in] NOTE: 0x80 */
{
DWORD ret;
LPWSTR lpwstrFile = HEAP_strdupAtoW(GetProcessHeap(), 0, lpstrFile);
INT len = MultiByteToWideChar( CP_ACP, 0, lpstrFile, -1, NULL, 0 );
LPWSTR lpwstrFile = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
MultiByteToWideChar( CP_ACP, 0, lpstrFile, -1, lpwstrFile, len );
ret = PrivateExtractIconsW(
lpwstrFile, nIndex, sizeX, sizeY, phicon, w, nIcons, y
);
@ -649,13 +650,13 @@ HRESULT WINAPI PrivateExtractIconExA (
UINT nIcons )
{
DWORD ret;
LPWSTR lpwstrFile = HEAP_strdupAtoW(GetProcessHeap(), 0, lpstrFile);
INT len = MultiByteToWideChar( CP_ACP, 0, lpstrFile, -1, NULL, 0 );
LPWSTR lpwstrFile = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
TRACE("%s 0x%08lx %p %p 0x%08x\n",
lpstrFile, nIndex, phIconLarge, phIconSmall, nIcons);
TRACE("%s 0x%08lx %p %p 0x%08x\n", lpstrFile, nIndex, phIconLarge, phIconSmall, nIcons);
MultiByteToWideChar( CP_ACP, 0, lpstrFile, -1, lpwstrFile, len );
ret = PrivateExtractIconExW(lpwstrFile,nIndex,phIconLarge, phIconSmall, nIcons);
HeapFree(GetProcessHeap(), 0, lpwstrFile);
return ret;
}

View File

@ -11,8 +11,6 @@
#include "winnls.h"
#include "wine/winbase16.h"
#include "wine/winuser16.h"
#include "heap.h"
#include "debugtools.h"
DEFAULT_DEBUG_CHANNEL(resource);
@ -99,15 +97,20 @@ HACCEL WINAPI LoadAcceleratorsW(HINSTANCE instance,LPCWSTR lpTableName)
*/
HACCEL WINAPI LoadAcceleratorsA(HINSTANCE instance,LPCSTR lpTableName)
{
LPWSTR uni;
HACCEL result;
if (HIWORD(lpTableName))
uni = HEAP_strdupAtoW( GetProcessHeap(), 0, lpTableName );
else
uni = (LPWSTR)lpTableName;
result = LoadAcceleratorsW(instance,uni);
if (HIWORD(uni)) HeapFree( GetProcessHeap(), 0, uni);
return result;
INT len;
LPWSTR uni;
HACCEL result = 0;
if (!HIWORD(lpTableName)) return LoadAcceleratorsW( instance, (LPCWSTR)lpTableName );
len = MultiByteToWideChar( CP_ACP, 0, lpTableName, -1, NULL, 0 );
if ((uni = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
{
MultiByteToWideChar( CP_ACP, 0, lpTableName, -1, uni, len );
result = LoadAcceleratorsW(instance,uni);
HeapFree( GetProcessHeap(), 0, uni);
}
return result;
}
/**********************************************************************

View File

@ -16,7 +16,6 @@
#include <time.h>
#include "winbase.h"
#include "winerror.h"
#include "heap.h"
#include "wine/server.h"
#include "debugtools.h"
@ -49,10 +48,17 @@ HANDLE WINAPI FindFirstChangeNotificationW( LPCWSTR lpPathName,
BOOL bWatchSubtree,
DWORD dwNotifyFilter)
{
LPSTR nameA = HEAP_strdupWtoA( GetProcessHeap(), 0, lpPathName );
HANDLE ret = FindFirstChangeNotificationA( nameA, bWatchSubtree,
dwNotifyFilter );
if (nameA) HeapFree( GetProcessHeap(), 0, nameA );
HANDLE ret = INVALID_HANDLE_VALUE;
FIXME("this is not supported yet (non-trivial).\n");
SERVER_START_REQ( create_change_notification )
{
req->subtree = bWatchSubtree;
req->filter = dwNotifyFilter;
if (!wine_server_call_err( req )) ret = reply->handle;
}
SERVER_END_REQ;
return ret;
}

View File

@ -9,7 +9,6 @@
#include "windef.h"
#include "wingdi.h"
#include "gdi.h"
#include "heap.h"
#include "enhmetafiledrv.h"
#include "debugtools.h"
@ -212,9 +211,12 @@ HDC WINAPI CreateEnhMetaFileA(
HDC hReturnDC;
DWORD len1, len2, total;
if(filename)
filenameW = HEAP_strdupAtoW( GetProcessHeap(), 0, filename );
if(filename)
{
total = MultiByteToWideChar( CP_ACP, 0, filename, -1, NULL, 0 );
filenameW = HeapAlloc( GetProcessHeap(), 0, total * sizeof(WCHAR) );
MultiByteToWideChar( CP_ACP, 0, filename, -1, filenameW, total );
}
if(description) {
len1 = strlen(description);
len2 = strlen(description + len1 + 1);

View File

@ -7,7 +7,6 @@
#include "windef.h"
#include "wine/winbase16.h"
#include "gdi.h"
#include "heap.h"
#include "metafile.h"
#include "metafiledrv.h"
#include "debugtools.h"
@ -241,9 +240,12 @@ HDC WINAPI CreateMetaFileA(
HDC WINAPI CreateMetaFileW(LPCWSTR filename)
{
LPSTR filenameA;
DWORD len;
HDC hReturnDC;
filenameA = HEAP_strdupWtoA( GetProcessHeap(), 0, filename );
len = WideCharToMultiByte( CP_ACP, 0, filename, -1, NULL, 0, NULL, NULL );
filenameA = HeapAlloc( GetProcessHeap(), 0, len );
WideCharToMultiByte( CP_ACP, 0, filename, -1, filenameA, len, NULL, NULL );
hReturnDC = CreateMetaFileA(filenameA);

View File

@ -20,7 +20,6 @@
#include "winnls.h"
#include "winerror.h"
#include "module.h"
#include "heap.h"
#include "stackframe.h"
#include "debugtools.h"
@ -143,6 +142,7 @@ static const IMAGE_RESOURCE_DIRECTORY *find_entry_by_nameA( const IMAGE_RESOURCE
{
const IMAGE_RESOURCE_DIRECTORY *ret = NULL;
LPWSTR nameW;
INT len;
if (!HIWORD(name)) return find_entry_by_id( dir, LOWORD(name), root );
if (name[0] == '#')
@ -150,8 +150,10 @@ static const IMAGE_RESOURCE_DIRECTORY *find_entry_by_nameA( const IMAGE_RESOURCE
return find_entry_by_id( dir, atoi(name+1), root );
}
if ((nameW = HEAP_strdupAtoW( GetProcessHeap(), 0, name )))
len = MultiByteToWideChar( CP_ACP, 0, name, -1, NULL, 0 );
if ((nameW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
{
MultiByteToWideChar( CP_ACP, 0, name, -1, nameW, len );
ret = find_entry_by_nameW( dir, nameW, root );
HeapFree( GetProcessHeap(), 0, nameW );
}

View File

@ -38,10 +38,10 @@
#include "winreg.h"
#include "wine/winbase16.h"
#include "file.h"
#include "heap.h"
#include "options.h"
#include "wine/server.h"
#include "wine/unicode.h"
#include "file.h"
#include "options.h"
#include "debugtools.h"
@ -1603,42 +1603,6 @@ LONG WINAPI RegUnLoadKeyA( HKEY hkey, LPCSTR lpSubKey )
}
/******************************************************************************
* RegRestoreKeyW [ADVAPI32.@]
*
* PARAMS
* hkey [I] Handle of key where restore begins
* lpFile [I] Address of filename containing saved tree
* dwFlags [I] Optional flags
*/
LONG WINAPI RegRestoreKeyW( HKEY hkey, LPCWSTR lpFile, DWORD dwFlags )
{
TRACE("(%x,%s,%ld)\n",hkey,debugstr_w(lpFile),dwFlags);
/* It seems to do this check before the hkey check */
if (!lpFile || !*lpFile)
return ERROR_INVALID_PARAMETER;
FIXME("(%x,%s,%ld): stub\n",hkey,debugstr_w(lpFile),dwFlags);
/* Check for file existence */
return ERROR_SUCCESS;
}
/******************************************************************************
* RegRestoreKeyA [ADVAPI32.@]
*/
LONG WINAPI RegRestoreKeyA( HKEY hkey, LPCSTR lpFile, DWORD dwFlags )
{
LPWSTR lpFileW = HEAP_strdupAtoW( GetProcessHeap(), 0, lpFile );
LONG ret = RegRestoreKeyW( hkey, lpFileW, dwFlags );
HeapFree( GetProcessHeap(), 0, lpFileW );
return ret;
}
/******************************************************************************
* RegReplaceKeyA [ADVAPI32.@]
*/

View File

@ -39,7 +39,6 @@
#include "wine/wingdi16.h"
#include "bitmap.h"
#include "global.h"
#include "heap.h"
#include "metafile.h"
#include "debugtools.h"
@ -436,9 +435,16 @@ HMETAFILE WINAPI CopyMetaFileA(
HMETAFILE WINAPI CopyMetaFileW( HMETAFILE hSrcMetaFile,
LPCWSTR lpFilename )
{
LPSTR p = HEAP_strdupWtoA( GetProcessHeap(), 0, lpFilename );
HMETAFILE ret = CopyMetaFileA( hSrcMetaFile, p );
HeapFree( GetProcessHeap(), 0, p );
HMETAFILE ret = 0;
DWORD len = WideCharToMultiByte( CP_ACP, 0, lpFilename, -1, NULL, 0, NULL, NULL );
LPSTR p = HeapAlloc( GetProcessHeap(), 0, len );
if (p)
{
WideCharToMultiByte( CP_ACP, 0, lpFilename, -1, p, len, NULL, NULL );
ret = CopyMetaFileA( hSrcMetaFile, p );
HeapFree( GetProcessHeap(), 0, p );
}
return ret;
}

View File

@ -17,7 +17,6 @@
#include "wingdi.h"
#include "winuser.h"
#include "wine/unicode.h"
#include "heap.h"
#include "options.h"
#include "winver.h"
#include "winnls.h"
@ -2243,12 +2242,9 @@ INT WINAPI LCMapStringW(
returned_len = wcstombs(src_native, srcstr_libc, src_native_len) + 1;
if(returned_len == 0)
{
LPSTR srcstr_ascii = (LPSTR)HEAP_strdupWtoA(GetProcessHeap(),
0, srcstr);
ERR("wcstombs failed. The string specified (%s) may contains an "
"invalid character.\n", srcstr_ascii);
ERR("wcstombs failed. The string specified (%s) may contain an invalid character.\n",
debugstr_w(srcstr));
SetLastError(ERROR_INVALID_PARAMETER);
if(srcstr_ascii) HeapFree(GetProcessHeap(), 0, srcstr_ascii);
if(srcstr_libc) HeapFree(GetProcessHeap(), 0, srcstr_libc);
if(src_native) HeapFree(GetProcessHeap(), 0, src_native);
setlocale(LC_COLLATE, lc_collate_default);

View File

@ -27,7 +27,6 @@
#include "wine/winbase16.h"
#include "file.h"
#include "heap.h"
#include "debugtools.h"
@ -106,8 +105,12 @@ BOOL WINAPI SetFileAttributesA(LPCSTR lpFileName, DWORD attributes)
*/
BOOL WINAPI SetFileAttributesW(LPCWSTR lpFileName, DWORD attributes)
{
LPSTR afn = HEAP_strdupWtoA( GetProcessHeap(), 0, lpFileName );
BOOL res = SetFileAttributesA( afn, attributes );
BOOL res;
DWORD len = WideCharToMultiByte( CP_ACP, 0, lpFileName, -1, NULL, 0, NULL, NULL );
LPSTR afn = HeapAlloc( GetProcessHeap(), 0, len );
WideCharToMultiByte( CP_ACP, 0, lpFileName, -1, afn, len, NULL, NULL );
res = SetFileAttributesA( afn, attributes );
HeapFree( GetProcessHeap(), 0, afn );
return res;
}

View File

@ -12,8 +12,9 @@ at a later date. */
#include <sys/time.h>
#include <unistd.h>
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "winerror.h"
#include "heap.h"
#include "debugtools.h"
DEFAULT_DEBUG_CHANNEL(win32);
@ -268,9 +269,13 @@ DWORD WINAPI GetCompressedFileSizeW(
*/
BOOL WINAPI SetComputerNameA( LPCSTR lpComputerName )
{
LPWSTR lpComputerNameW = HEAP_strdupAtoW(GetProcessHeap(),0,lpComputerName);
BOOL ret = SetComputerNameW(lpComputerNameW);
HeapFree(GetProcessHeap(),0,lpComputerNameW);
BOOL ret;
DWORD len = MultiByteToWideChar( CP_ACP, 0, lpComputerName, -1, NULL, 0 );
LPWSTR nameW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
MultiByteToWideChar( CP_ACP, 0, lpComputerName, -1, nameW, len );
ret = SetComputerNameW( nameW );
HeapFree( GetProcessHeap(), 0, nameW );
return ret;
}

View File

@ -37,7 +37,6 @@
#include "wine/winbase16.h"
#include "wine/winuser16.h"
#include "wine/exception.h"
#include "heap.h"
#include "palette.h"
#include "bitmap.h"
#include "cursoricon.h"
@ -2191,9 +2190,13 @@ HANDLE WINAPI LoadImageA( HINSTANCE hinst, LPCSTR name, UINT type,
HANDLE res;
LPWSTR u_name;
if (!HIWORD(name))
return LoadImageW(hinst, (LPWSTR)name, type, desiredx, desiredy, loadflags);
__TRY {
if (HIWORD(name)) u_name = HEAP_strdupAtoW(GetProcessHeap(), 0, name);
else u_name=(LPWSTR)name;
DWORD len = MultiByteToWideChar( CP_ACP, 0, name, -1, NULL, 0 );
u_name = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
MultiByteToWideChar( CP_ACP, 0, name, -1, u_name, len );
}
__EXCEPT(page_fault) {
SetLastError( ERROR_INVALID_PARAMETER );
@ -2201,7 +2204,7 @@ HANDLE WINAPI LoadImageA( HINSTANCE hinst, LPCSTR name, UINT type,
}
__ENDTRY
res = LoadImageW(hinst, u_name, type, desiredx, desiredy, loadflags);
if (HIWORD(name)) HeapFree(GetProcessHeap(), 0, u_name);
HeapFree(GetProcessHeap(), 0, u_name);
return res;
}

View File

@ -77,7 +77,6 @@
#include "winuser.h"
#include "wine/unicode.h"
#include "win.h"
#include "heap.h"
#include "nonclient.h"
#include "controls.h"
#include "user.h"
@ -1459,7 +1458,9 @@ LRESULT WINAPI DefFrameProcA( HWND hwnd, HWND hwndMDIClient,
{
case WM_SETTEXT:
{
LPWSTR text = HEAP_strdupAtoW( GetProcessHeap(), 0, (LPSTR)lParam );
DWORD len = MultiByteToWideChar( CP_ACP, 0, (LPSTR)lParam, -1, NULL, 0 );
LPWSTR text = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
MultiByteToWideChar( CP_ACP, 0, (LPSTR)lParam, -1, text, len );
MDI_UpdateFrameText(hwnd, hwndMDIClient, MDI_REPAINTFRAME, text );
HeapFree( GetProcessHeap(), 0, text );
}

View File

@ -11,7 +11,6 @@
#include "version.h"
#include "win.h"
#include "user.h"
#include "heap.h"
#include "dce.h"
#include "controls.h"
#include "cursoricon.h"
@ -259,22 +258,38 @@ DrawCaption (HWND hwnd, HDC hdc, const RECT *lpRect, UINT uFlags)
/***********************************************************************
* DrawCaptionTempA (USER32.@)
*
* PARAMS
*
* RETURNS
* Success:
* Failure:
*/
BOOL WINAPI DrawCaptionTempA (HWND hwnd, HDC hdc, const RECT *rect, HFONT hFont,
HICON hIcon, LPCSTR str, UINT uFlags)
{
LPWSTR strW;
INT len;
BOOL ret = FALSE;
BOOL WINAPI
DrawCaptionTempA (HWND hwnd, HDC hdc, const RECT *rect, HFONT hFont,
HICON hIcon, LPCSTR str, UINT uFlags)
if (!(uFlags & DC_TEXT) || !str)
return DrawCaptionTempW( hwnd, hdc, rect, hFont, hIcon, NULL, uFlags );
len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
if ((strW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
{
MultiByteToWideChar( CP_ACP, 0, str, -1, strW, len );
ret = DrawCaptionTempW (hwnd, hdc, rect, hFont, hIcon, strW, uFlags);
HeapFree( GetProcessHeap (), 0, strW );
}
return ret;
}
/***********************************************************************
* DrawCaptionTempW (USER32.@)
*/
BOOL WINAPI DrawCaptionTempW (HWND hwnd, HDC hdc, const RECT *rect, HFONT hFont,
HICON hIcon, LPCWSTR str, UINT uFlags)
{
RECT rc = *rect;
TRACE("(%08x,%08x,%p,%08x,%08x,\"%s\",%08x)\n",
hwnd, hdc, rect, hFont, hIcon, str, uFlags);
TRACE("(%08x,%08x,%p,%08x,%08x,%s,%08x)\n",
hwnd, hdc, rect, hFont, hIcon, debugstr_w(str), uFlags);
/* drawing background */
if (uFlags & DC_INBUTTON) {
@ -332,13 +347,13 @@ DrawCaptionTempA (HWND hwnd, HDC hdc, const RECT *rect, HFONT hFont,
}
if (str)
DrawTextA (hdc, str, -1, &rc,
DrawTextW (hdc, str, -1, &rc,
DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT);
else {
CHAR szText[128];
WCHAR szText[128];
INT nLen;
nLen = GetWindowTextA (hwnd, szText, 128);
DrawTextA (hdc, szText, nLen, &rc,
nLen = GetWindowTextW (hwnd, szText, 128);
DrawTextW (hdc, szText, nLen, &rc,
DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT);
}
@ -356,27 +371,6 @@ DrawCaptionTempA (HWND hwnd, HDC hdc, const RECT *rect, HFONT hFont,
}
/***********************************************************************
* DrawCaptionTempW (USER32.@)
*
* PARAMS
*
* RETURNS
* Success:
* Failure:
*/
BOOL WINAPI
DrawCaptionTempW (HWND hwnd, HDC hdc, const RECT *rect, HFONT hFont,
HICON hIcon, LPCWSTR str, UINT uFlags)
{
LPSTR p = HEAP_strdupWtoA (GetProcessHeap (), 0, str);
BOOL res = DrawCaptionTempA (hwnd, hdc, rect, hFont, hIcon, p, uFlags);
HeapFree (GetProcessHeap (), 0, p);
return res;
}
/***********************************************************************
* AdjustWindowRect (USER.102)
*/

View File

@ -12,7 +12,6 @@
#include "wingdi.h"
#include "winuser.h"
#include "wine/winuser16.h"
#include "heap.h"
#include "user.h"
#include "win.h"
#include "controls.h"
@ -364,21 +363,26 @@ BOOL WINAPI EnumDisplaySettingsA(
/***********************************************************************
* EnumDisplaySettingsW (USER32.@)
*/
BOOL WINAPI EnumDisplaySettingsW(LPCWSTR name,DWORD n,LPDEVMODEW devmode) {
LPSTR nameA = HEAP_strdupWtoA(GetProcessHeap(),0,name);
DEVMODEA devmodeA;
BOOL ret = EnumDisplaySettingsA(nameA,n,&devmodeA);
BOOL WINAPI EnumDisplaySettingsW(LPCWSTR name,DWORD n,LPDEVMODEW devmode)
{
DEVMODEA devmodeA;
BOOL ret;
DWORD len = WideCharToMultiByte( CP_ACP, 0, name, -1, NULL, 0, NULL, NULL );
LPSTR nameA = HeapAlloc( GetProcessHeap(), 0, len );
if (ret) {
devmode->dmBitsPerPel = devmodeA.dmBitsPerPel;
devmode->dmPelsHeight = devmodeA.dmPelsHeight;
devmode->dmPelsWidth = devmodeA.dmPelsWidth;
devmode->dmDisplayFlags = devmodeA.dmDisplayFlags;
devmode->dmDisplayFrequency = devmodeA.dmDisplayFrequency;
/* FIXME: convert rest too, if they are ever returned */
}
HeapFree(GetProcessHeap(),0,nameA);
return ret;
WideCharToMultiByte( CP_ACP, 0, name, -1, nameA, len, NULL, NULL );
ret = EnumDisplaySettingsA(nameA,n,&devmodeA);
if (ret)
{
devmode->dmBitsPerPel = devmodeA.dmBitsPerPel;
devmode->dmPelsHeight = devmodeA.dmPelsHeight;
devmode->dmPelsWidth = devmodeA.dmPelsWidth;
devmode->dmDisplayFlags = devmodeA.dmDisplayFlags;
devmode->dmDisplayFrequency = devmodeA.dmDisplayFrequency;
/* FIXME: convert rest too, if they are ever returned */
}
HeapFree(GetProcessHeap(),0,nameA);
return ret;
}
/***********************************************************************

View File

@ -13,7 +13,6 @@
#include "wine/server.h"
#include "wine/unicode.h"
#include "win.h"
#include "heap.h"
#include "user.h"
#include "dce.h"
#include "controls.h"
@ -1602,6 +1601,7 @@ HWND WINAPI FindWindowExA( HWND parent, HWND child,
ATOM atom = 0;
LPWSTR buffer;
HWND hwnd;
INT len;
if (className)
{
@ -1613,8 +1613,11 @@ HWND WINAPI FindWindowExA( HWND parent, HWND child,
return 0;
}
}
if (!title) return WIN_FindWindow( parent, child, atom, NULL );
buffer = HEAP_strdupAtoW( GetProcessHeap(), 0, title );
len = MultiByteToWideChar( CP_ACP, 0, title, -1, NULL, 0 );
if (!(buffer = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) return 0;
MultiByteToWideChar( CP_ACP, 0, title, -1, buffer, len );
hwnd = WIN_FindWindow( parent, child, atom, buffer );
HeapFree( GetProcessHeap(), 0, buffer );
return hwnd;

View File

@ -12,7 +12,6 @@
#include "wine/winuser16.h"
#include "wine/winbase16.h"
#include "win.h"
#include "heap.h"
DEFAULT_DEBUG_CHANNEL(win);
@ -144,11 +143,20 @@ BOOL WINAPI WinHelpA( HWND hWnd, LPCSTR lpHelpFile, UINT wCommand,
/**********************************************************************
* WinHelpW (USER32.@)
*/
BOOL WINAPI WinHelpW( HWND hWnd, LPCWSTR helpFile, UINT command,
DWORD dwData )
BOOL WINAPI WinHelpW( HWND hWnd, LPCWSTR helpFile, UINT command, DWORD dwData )
{
LPSTR file = HEAP_strdupWtoA( GetProcessHeap(), 0, helpFile );
BOOL ret = WinHelpA( hWnd, file, command, dwData );
HeapFree( GetProcessHeap(), 0, file );
INT len;
LPSTR file;
BOOL ret = FALSE;
if (!helpFile) return WinHelpA( hWnd, NULL, command, dwData );
len = WideCharToMultiByte( CP_ACP, 0, helpFile, -1, NULL, 0, NULL, NULL );
if ((file = HeapAlloc( GetProcessHeap(), 0, len )))
{
WideCharToMultiByte( CP_ACP, 0, helpFile, -1, file, len, NULL, NULL );
ret = WinHelpA( hWnd, file, command, dwData );
HeapFree( GetProcessHeap(), 0, file );
}
return ret;
}