Jacek Caban : hhctrl.ocx: Declare strdupAtoW in hhctrl.
h and use it instead of duplicated *ANSIToUnicode.
Alexandre Julliard
julliard at wine.codeweavers.com
Fri Feb 23 05:28:19 CST 2007
Module: wine
Branch: master
Commit: 9a20d35cc8952a120ae146fbe35c23d0bc0580eb
URL: http://source.winehq.org/git/wine.git/?a=commit;h=9a20d35cc8952a120ae146fbe35c23d0bc0580eb
Author: Jacek Caban <jacek at codeweavers.com>
Date: Thu Feb 22 22:47:21 2007 +0100
hhctrl.ocx: Declare strdupAtoW in hhctrl.h and use it instead of duplicated *ANSIToUnicode.
---
dlls/hhctrl.ocx/chm.c | 14 +-------------
dlls/hhctrl.ocx/help.c | 14 +-------------
dlls/hhctrl.ocx/hhctrl.h | 15 +++++++++++++++
3 files changed, 17 insertions(+), 26 deletions(-)
diff --git a/dlls/hhctrl.ocx/chm.c b/dlls/hhctrl.ocx/chm.c
index c59fd71..3e105b0 100644
--- a/dlls/hhctrl.ocx/chm.c
+++ b/dlls/hhctrl.ocx/chm.c
@@ -20,18 +20,6 @@
#include "hhctrl.h"
-static LPWSTR CHM_ANSIToUnicode(LPCSTR ansi)
-{
- LPWSTR unicode;
- int count;
-
- count = MultiByteToWideChar(CP_ACP, 0, ansi, -1, NULL, 0);
- unicode = HeapAlloc(GetProcessHeap(), 0, count * sizeof(WCHAR));
- MultiByteToWideChar(CP_ACP, 0, ansi, -1, unicode, count);
-
- return unicode;
-}
-
/* Reads a string from the #STRINGS section in the CHM file */
static LPWSTR CHM_ReadString(CHMInfo *pChmInfo, DWORD dwOffset)
{
@@ -70,7 +58,7 @@ static LPWSTR CHM_ReadString(CHMInfo *pChmInfo, DWORD dwOffset)
{
if (!szString[iPos])
{
- stringW = CHM_ANSIToUnicode(szString);
+ stringW = strdupAtoW(szString);
HeapFree(GetProcessHeap(), 0, szString);
return stringW;
}
diff --git a/dlls/hhctrl.ocx/help.c b/dlls/hhctrl.ocx/help.c
index beb6285..39d750b 100644
--- a/dlls/hhctrl.ocx/help.c
+++ b/dlls/hhctrl.ocx/help.c
@@ -57,18 +57,6 @@ typedef struct tagHHInfo
extern HINSTANCE hhctrl_hinstance;
-static LPWSTR HH_ANSIToUnicode(LPCSTR ansi)
-{
- LPWSTR unicode;
- int count;
-
- count = MultiByteToWideChar(CP_ACP, 0, ansi, -1, NULL, 0);
- unicode = HeapAlloc(GetProcessHeap(), 0, count * sizeof(WCHAR));
- MultiByteToWideChar(CP_ACP, 0, ansi, -1, unicode, count);
-
- return unicode;
-}
-
/* Loads a string from the resource file */
static LPWSTR HH_LoadString(DWORD dwID)
{
@@ -861,7 +849,7 @@ int WINAPI doWinMain(HINSTANCE hInstance, LPSTR szCmdLine)
if (FAILED(OleInitialize(NULL)))
return -1;
- pHHInfo = HH_OpenHH(hInstance, HH_ANSIToUnicode(szCmdLine));
+ pHHInfo = HH_OpenHH(hInstance, strdupAtoW(szCmdLine));
if (!pHHInfo || !HH_OpenCHM(pHHInfo) || !HH_CreateViewer(pHHInfo))
{
OleUninitialize();
diff --git a/dlls/hhctrl.ocx/hhctrl.h b/dlls/hhctrl.ocx/hhctrl.h
index 17e5ac8..367564b 100644
--- a/dlls/hhctrl.ocx/hhctrl.h
+++ b/dlls/hhctrl.ocx/hhctrl.h
@@ -70,4 +70,19 @@ BOOL CHM_OpenCHM(CHMInfo *pCHMInfo, LPCWSTR szFile);
BOOL CHM_LoadWinTypeFromCHM(CHMInfo *pCHMInfo, HH_WINTYPEW *pHHWinType);
void CHM_CloseCHM(CHMInfo *pCHMInfo);
+static inline LPWSTR strdupAtoW(LPCSTR str)
+{
+ LPWSTR ret;
+ DWORD len;
+
+ if(!str)
+ return NULL;
+
+ len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
+ ret = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
+ MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
+
+ return ret;
+}
+
#endif
More information about the wine-cvs
mailing list