Commit 07ba4577 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

hhctrl.ocx: Use wrappers of memory allocation functions.

parent 5faa1f6b
......@@ -36,7 +36,7 @@ static LPWSTR CHM_ReadString(CHMInfo *pChmInfo, DWORD dwOffset)
static const WCHAR stringsW[] = {'#','S','T','R','I','N','G','S',0};
dwSize = CB_READ_BLOCK;
szString = HeapAlloc(GetProcessHeap(), 0, dwSize);
szString = hhctrl_alloc(dwSize);
if (FAILED(IStorage_OpenStream(pStorage, stringsW, NULL, STGM_READ, 0, &pStream)))
return NULL;
......@@ -59,13 +59,13 @@ static LPWSTR CHM_ReadString(CHMInfo *pChmInfo, DWORD dwOffset)
if (!szString[iPos])
{
stringW = strdupAtoW(szString);
HeapFree(GetProcessHeap(), 0, szString);
hhctrl_free(szString);
return stringW;
}
}
dwSize *= 2;
szString = HeapReAlloc(GetProcessHeap(), 0, szString, dwSize);
szString = hhctrl_realloc(szString, dwSize);
szString += cbRead;
}
......
......@@ -66,7 +66,7 @@ static LPWSTR HH_LoadString(DWORD dwID)
iSize = LoadStringW(hhctrl_hinstance, dwID, NULL, 0);
iSize += 2; /* some strings (tab text) needs double-null termination */
string = HeapAlloc(GetProcessHeap(), 0, iSize * sizeof(WCHAR));
string = hhctrl_alloc(iSize * sizeof(WCHAR));
LoadStringW(hhctrl_hinstance, dwID, string, iSize);
return string;
......@@ -457,7 +457,7 @@ static BOOL HH_AddToolbar(HHInfo *pHHInfo)
szBuf[dwLen + 2] = 0; /* Double-null terminate */
buttons[dwIndex].iString = (DWORD)SendMessageW(hToolbar, TB_ADDSTRINGW, 0, (LPARAM)szBuf);
HeapFree(GetProcessHeap(), 0, szBuf);
hhctrl_free(szBuf);
}
SendMessageW(hToolbar, TB_ADDBUTTONSW, dwNumButtons, (LPARAM)&buttons);
......@@ -504,7 +504,7 @@ static void NP_CreateTab(HINSTANCE hInstance, HWND hwndTabCtrl, DWORD dwStrID, D
tie.pszText = tabText;
SendMessageW( hwndTabCtrl, TCM_INSERTITEMW, dwIndex, (LPARAM)&tie );
HeapFree(GetProcessHeap(), 0, tabText);
hhctrl_free(tabText);
}
static BOOL HH_AddNavigationPane(HHInfo *pHHInfo)
......@@ -782,11 +782,11 @@ static BOOL HH_CreateViewer(HHInfo *pHHInfo)
static HHInfo *HH_OpenHH(HINSTANCE hInstance, LPWSTR szCmdLine)
{
HHInfo *pHHInfo = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(HHInfo));
HHInfo *pHHInfo = hhctrl_alloc_zero(sizeof(HHInfo));
pHHInfo->pHHWinType = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(HH_WINTYPEW));
pHHInfo->pCHMInfo = HeapAlloc(GetProcessHeap(), 0, sizeof(CHMInfo));
pHHInfo->pWBInfo = HeapAlloc(GetProcessHeap(), 0, sizeof(WBInfo));
pHHInfo->pHHWinType = hhctrl_alloc_zero(sizeof(HH_WINTYPEW));
pHHInfo->pCHMInfo = hhctrl_alloc(sizeof(CHMInfo));
pHHInfo->pWBInfo = hhctrl_alloc(sizeof(WBInfo));
pHHInfo->hInstance = hInstance;
pHHInfo->szCmdLine = szCmdLine;
......@@ -801,31 +801,31 @@ static void HH_Close(HHInfo *pHHInfo)
/* Free allocated strings */
if (pHHInfo->pHHWinType)
{
HeapFree(GetProcessHeap(), 0, (LPWSTR)pHHInfo->pHHWinType->pszType);
HeapFree(GetProcessHeap(), 0, (LPWSTR)pHHInfo->pHHWinType->pszCaption);
HeapFree(GetProcessHeap(), 0, (LPWSTR)pHHInfo->pHHWinType->pszToc);
HeapFree(GetProcessHeap(), 0, (LPWSTR)pHHInfo->pHHWinType->pszIndex);
HeapFree(GetProcessHeap(), 0, (LPWSTR)pHHInfo->pHHWinType->pszFile);
HeapFree(GetProcessHeap(), 0, (LPWSTR)pHHInfo->pHHWinType->pszHome);
HeapFree(GetProcessHeap(), 0, (LPWSTR)pHHInfo->pHHWinType->pszJump1);
HeapFree(GetProcessHeap(), 0, (LPWSTR)pHHInfo->pHHWinType->pszJump2);
HeapFree(GetProcessHeap(), 0, (LPWSTR)pHHInfo->pHHWinType->pszUrlJump1);
HeapFree(GetProcessHeap(), 0, (LPWSTR)pHHInfo->pHHWinType->pszUrlJump2);
hhctrl_free((LPWSTR)pHHInfo->pHHWinType->pszType);
hhctrl_free((LPWSTR)pHHInfo->pHHWinType->pszCaption);
hhctrl_free((LPWSTR)pHHInfo->pHHWinType->pszToc);
hhctrl_free((LPWSTR)pHHInfo->pHHWinType->pszIndex);
hhctrl_free((LPWSTR)pHHInfo->pHHWinType->pszFile);
hhctrl_free((LPWSTR)pHHInfo->pHHWinType->pszHome);
hhctrl_free((LPWSTR)pHHInfo->pHHWinType->pszJump1);
hhctrl_free((LPWSTR)pHHInfo->pHHWinType->pszJump2);
hhctrl_free((LPWSTR)pHHInfo->pHHWinType->pszUrlJump1);
hhctrl_free((LPWSTR)pHHInfo->pHHWinType->pszUrlJump2);
}
HeapFree(GetProcessHeap(), 0, pHHInfo->pHHWinType);
HeapFree(GetProcessHeap(), 0, pHHInfo->szCmdLine);
hhctrl_free(pHHInfo->pHHWinType);
hhctrl_free(pHHInfo->szCmdLine);
if (pHHInfo->pCHMInfo)
{
CHM_CloseCHM(pHHInfo->pCHMInfo);
HeapFree(GetProcessHeap(), 0, pHHInfo->pCHMInfo);
hhctrl_free(pHHInfo->pCHMInfo);
}
if (pHHInfo->pWBInfo)
{
WB_UnEmbedBrowser(pHHInfo->pWBInfo);
HeapFree(GetProcessHeap(), 0, pHHInfo->pWBInfo);
hhctrl_free(pHHInfo->pWBInfo);
}
}
......@@ -865,7 +865,7 @@ int WINAPI doWinMain(HINSTANCE hInstance, LPSTR szCmdLine)
}
HH_Close(pHHInfo);
HeapFree(GetProcessHeap(), 0, pHHInfo);
hhctrl_free(pHHInfo);
OleUninitialize();
return 0;
......
......@@ -97,7 +97,7 @@ HWND WINAPI HtmlHelpW(HWND caller, LPCWSTR filename, UINT command, DWORD data)
{
DWORD len = WideCharToMultiByte( CP_ACP, 0, filename, -1, NULL, 0, NULL, NULL );
file = HeapAlloc( GetProcessHeap(), 0, len );
file = hhctrl_alloc(len);
WideCharToMultiByte( CP_ACP, 0, filename, -1, file, len, NULL, NULL );
}
......@@ -113,7 +113,7 @@ HWND WINAPI HtmlHelpW(HWND caller, LPCWSTR filename, UINT command, DWORD data)
default:
FIXME("HH case %s not handled.\n", command_to_string( command ));
}
HeapFree(GetProcessHeap(), 0, file);
hhctrl_free(file);
return 0;
}
......@@ -126,12 +126,12 @@ HWND WINAPI HtmlHelpA(HWND caller, LPCSTR filename, UINT command, DWORD data)
{
DWORD len = MultiByteToWideChar( CP_ACP, 0, filename, -1, NULL, 0 );
wfile = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR));
wfile = hhctrl_alloc(len*sizeof(WCHAR));
MultiByteToWideChar( CP_ACP, 0, filename, -1, wfile, len );
}
result = HtmlHelpW( caller, wfile, command, data );
HeapFree( GetProcessHeap(), 0, wfile );
hhctrl_free(wfile);
return result;
}
......@@ -70,6 +70,28 @@ BOOL CHM_OpenCHM(CHMInfo *pCHMInfo, LPCWSTR szFile);
BOOL CHM_LoadWinTypeFromCHM(CHMInfo *pCHMInfo, HH_WINTYPEW *pHHWinType);
void CHM_CloseCHM(CHMInfo *pCHMInfo);
/* memory allocation functions */
static inline void *hhctrl_alloc(size_t len)
{
return HeapAlloc(GetProcessHeap(), 0, len);
}
static inline void *hhctrl_alloc_zero(size_t len)
{
return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
}
static inline void *hhctrl_realloc(void *mem, size_t len)
{
return HeapReAlloc(GetProcessHeap(), 0, mem, len);
}
static inline BOOL hhctrl_free(void *mem)
{
return HeapFree(GetProcessHeap(), 0, mem);
}
static inline LPWSTR strdupAtoW(LPCSTR str)
{
LPWSTR ret;
......@@ -79,7 +101,7 @@ static inline LPWSTR strdupAtoW(LPCSTR str)
return NULL;
len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
ret = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
ret = hhctrl_alloc(len*sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
return ret;
......
......@@ -74,7 +74,7 @@ static ULONG STDMETHODCALLTYPE Site_Release(IOleClientSite *iface)
if (refCount)
return refCount;
HeapFree(GetProcessHeap(), 0, This);
hhctrl_free(This);
return 0;
}
......@@ -579,8 +579,7 @@ BOOL WB_EmbedBrowser(WBInfo *pWBInfo, HWND hwndParent)
/* clear out struct to keep from accessing invalid ptrs */
ZeroMemory(pWBInfo, sizeof(WBInfo));
iOleClientSiteImpl = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(IOleClientSiteImpl));
iOleClientSiteImpl = hhctrl_alloc_zero(sizeof(IOleClientSiteImpl));
if (!iOleClientSiteImpl)
return FALSE;
......@@ -631,7 +630,7 @@ BOOL WB_EmbedBrowser(WBInfo *pWBInfo, HWND hwndParent)
error:
WB_UnEmbedBrowser(pWBInfo);
HeapFree(GetProcessHeap(), 0, iOleClientSiteImpl);
hhctrl_free(iOleClientSiteImpl);
return FALSE;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment