Commit 9dba420d authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

hhctrl: Use standard C functions for memory allocation.

parent 7ed17ec2
......@@ -33,25 +33,20 @@ static LPCSTR GetChmString(CHMInfo *chm, DWORD offset)
{
LPCSTR str;
char **new_strings;
DWORD new_strings_size;
if(!chm->strings_stream)
return NULL;
if(chm->strings_size <= (offset >> BLOCK_BITS)) {
chm->strings_size = (offset >> BLOCK_BITS)+1;
if(chm->strings) {
new_strings = heap_realloc_zero(chm->strings,
chm->strings_size*sizeof(char*));
new_strings_size = (offset >> BLOCK_BITS) + 1;
new_strings = realloc(chm->strings, new_strings_size * sizeof(char*));
if(!new_strings)
return NULL;
memset(new_strings + chm->strings_size, 0,
(new_strings_size - chm->strings_size) * sizeof(char*));
chm->strings = new_strings;
}else {
chm->strings = heap_alloc_zero(
chm->strings_size*sizeof(char*));
if(!chm->strings)
return NULL;
}
chm->strings_size = new_strings_size;
}
if(!chm->strings[offset >> BLOCK_BITS]) {
......@@ -66,13 +61,13 @@ static LPCSTR GetChmString(CHMInfo *chm, DWORD offset)
return NULL;
}
chm->strings[offset >> BLOCK_BITS] = heap_alloc(BLOCK_SIZE);
chm->strings[offset >> BLOCK_BITS] = malloc(BLOCK_SIZE);
hres = IStream_Read(chm->strings_stream, chm->strings[offset >> BLOCK_BITS],
BLOCK_SIZE, &read);
if(FAILED(hres)) {
WARN("Read failed: %08lx\n", hres);
heap_free(chm->strings[offset >> BLOCK_BITS]);
free(chm->strings[offset >> BLOCK_BITS]);
chm->strings[offset >> BLOCK_BITS] = NULL;
return NULL;
}
......@@ -106,7 +101,7 @@ static BOOL ReadChmSystem(CHMInfo *chm)
IStream_Read(stream, &ver, sizeof(ver), &read);
TRACE("version is %lx\n", ver);
buf = heap_alloc(8*sizeof(DWORD));
buf = malloc(8 * sizeof(DWORD));
buf_size = 8*sizeof(DWORD);
while(1) {
......@@ -115,7 +110,7 @@ static BOOL ReadChmSystem(CHMInfo *chm)
break;
if(entry.len > buf_size)
buf = heap_realloc(buf, buf_size=entry.len);
buf = realloc(buf, buf_size=entry.len);
hres = IStream_Read(stream, buf, entry.len, &read);
if(hres != S_OK)
......@@ -124,17 +119,17 @@ static BOOL ReadChmSystem(CHMInfo *chm)
switch(entry.code) {
case 0x0:
TRACE("TOC is %s\n", debugstr_an(buf, entry.len));
heap_free(chm->defToc);
free(chm->defToc);
chm->defToc = strdupnAtoW(buf, entry.len);
break;
case 0x2:
TRACE("Default topic is %s\n", debugstr_an(buf, entry.len));
heap_free(chm->defTopic);
free(chm->defTopic);
chm->defTopic = strdupnAtoW(buf, entry.len);
break;
case 0x3:
TRACE("Title is %s\n", debugstr_an(buf, entry.len));
heap_free(chm->defTitle);
free(chm->defTitle);
chm->defTitle = strdupnAtoW(buf, entry.len);
break;
case 0x4:
......@@ -150,7 +145,7 @@ static BOOL ReadChmSystem(CHMInfo *chm)
break;
case 0x6:
TRACE("Compiled file is %s\n", debugstr_an(buf, entry.len));
heap_free(chm->compiledFile);
free(chm->compiledFile);
chm->compiledFile = strdupnAtoW(buf, entry.len);
break;
case 0x9:
......@@ -170,7 +165,7 @@ static BOOL ReadChmSystem(CHMInfo *chm)
}
}
heap_free(buf);
free(buf);
IStream_Release(stream);
return SUCCEEDED(hres);
......@@ -199,12 +194,12 @@ LPWSTR FindContextAlias(CHMInfo *chm, DWORD index)
return NULL;
}
buf = heap_alloc(size);
buf = malloc(size);
hres = IStream_Read(ivb_stream, buf, size, &read);
IStream_Release(ivb_stream);
if(FAILED(hres)) {
WARN("Read failed: %08lx\n", hres);
heap_free(buf);
free(buf);
return NULL;
}
......@@ -217,7 +212,7 @@ LPWSTR FindContextAlias(CHMInfo *chm, DWORD index)
}
}
heap_free(buf);
free(buf);
TRACE("returning %s\n", debugstr_a(ret));
return strdupAtoW(ret);
......@@ -235,15 +230,15 @@ static WCHAR *FindHTMLHelpSetting(HHInfo *info, const WCHAR *extW)
WCHAR *filename;
HRESULT hr;
filename = heap_alloc( (lstrlenW(info->pCHMInfo->compiledFile)
+ lstrlenW(periodW) + lstrlenW(extW) + 1) * sizeof(WCHAR) );
filename = malloc( (wcslen(info->pCHMInfo->compiledFile)
+ wcslen(periodW) + wcslen(extW) + 1) * sizeof(WCHAR) );
lstrcpyW(filename, info->pCHMInfo->compiledFile);
lstrcatW(filename, periodW);
lstrcatW(filename, extW);
hr = IStorage_OpenStream(pStorage, filename, NULL, STGM_READ, 0, &pStream);
if (FAILED(hr))
{
heap_free(filename);
free(filename);
return strdupAtoW("");
}
IStream_Release(pStream);
......@@ -253,7 +248,7 @@ static WCHAR *FindHTMLHelpSetting(HHInfo *info, const WCHAR *extW)
static inline WCHAR *MergeChmString(LPCWSTR src, WCHAR **dst)
{
if(*dst == NULL)
*dst = strdupW(src);
*dst = wcsdup(src);
return *dst;
}
......@@ -326,18 +321,18 @@ static inline WCHAR *ConvertChmString(HHInfo *info, DWORD id)
static inline void wintype_free(HH_WINTYPEW *wintype)
{
heap_free((void *)wintype->pszType);
heap_free((void *)wintype->pszCaption);
heap_free(wintype->paInfoTypes);
heap_free((void *)wintype->pszToc);
heap_free((void *)wintype->pszIndex);
heap_free((void *)wintype->pszFile);
heap_free((void *)wintype->pszHome);
heap_free((void *)wintype->pszJump1);
heap_free((void *)wintype->pszJump2);
heap_free((void *)wintype->pszUrlJump1);
heap_free((void *)wintype->pszUrlJump2);
heap_free((void *)wintype->pszCustomTabs);
free((void *)wintype->pszType);
free((void *)wintype->pszCaption);
free(wintype->paInfoTypes);
free((void *)wintype->pszToc);
free((void *)wintype->pszIndex);
free((void *)wintype->pszFile);
free((void *)wintype->pszHome);
free((void *)wintype->pszJump1);
free((void *)wintype->pszJump2);
free((void *)wintype->pszUrlJump1);
free((void *)wintype->pszUrlJump2);
free((void *)wintype->pszCustomTabs);
}
/* Loads the HH_WINTYPE data from the CHM file
......@@ -452,9 +447,9 @@ BOOL LoadWinTypeFromCHM(HHInfo *info)
{
/* no defined window types so use (hopefully) sane defaults */
static const WCHAR defaultwinW[] = {'d','e','f','a','u','l','t','w','i','n','\0'};
wintype.pszType = strdupW(info->pCHMInfo->defWindow ? info->pCHMInfo->defWindow : defaultwinW);
wintype.pszToc = strdupW(info->pCHMInfo->defToc ? info->pCHMInfo->defToc : empty);
wintype.pszIndex = strdupW(empty);
wintype.pszType = wcsdup(info->pCHMInfo->defWindow ? info->pCHMInfo->defWindow : defaultwinW);
wintype.pszToc = wcsdup(info->pCHMInfo->defToc ? info->pCHMInfo->defToc : empty);
wintype.pszIndex = wcsdup(empty);
wintype.fsValidMembers = 0;
wintype.fsWinProperties = HHWIN_PROP_TRI_PANE;
wintype.dwStyles = WS_POPUP;
......@@ -466,9 +461,9 @@ BOOL LoadWinTypeFromCHM(HHInfo *info)
/* merge the new data with any pre-existing HH_WINTYPE structure */
MergeChmProperties(&wintype, info, FALSE);
if (!info->WinType.pszCaption)
info->WinType.pszCaption = info->stringsW.pszCaption = strdupW(info->pCHMInfo->defTitle ? info->pCHMInfo->defTitle : empty);
info->WinType.pszCaption = info->stringsW.pszCaption = wcsdup(info->pCHMInfo->defTitle ? info->pCHMInfo->defTitle : empty);
if (!info->WinType.pszFile)
info->WinType.pszFile = info->stringsW.pszFile = strdupW(info->pCHMInfo->defTopic ? info->pCHMInfo->defTopic : empty);
info->WinType.pszFile = info->stringsW.pszFile = wcsdup(info->pCHMInfo->defTopic ? info->pCHMInfo->defTopic : empty);
if (!info->WinType.pszToc)
info->WinType.pszToc = info->stringsW.pszToc = FindHTMLHelpSetting(info, toc_extW);
if (!info->WinType.pszIndex)
......@@ -524,14 +519,14 @@ void SetChmPath(ChmPath *file, LPCWSTR base_file, LPCWSTR path)
PathCombineW(chm_file, base_path, rel_path);
file->chm_file = strdupW(chm_file);
file->chm_file = wcsdup(chm_file);
ptr += 2;
}else {
file->chm_file = strdupW(base_file);
file->chm_file = wcsdup(base_file);
ptr = path;
}
file->chm_index = strdupW(ptr);
file->chm_index = wcsdup(ptr);
TRACE("ChmFile = {%s %s}\n", debugstr_w(file->chm_file), debugstr_w(file->chm_index));
}
......@@ -630,12 +625,12 @@ CHMInfo *OpenCHM(LPCWSTR szFile)
static const WCHAR wszSTRINGS[] = {'#','S','T','R','I','N','G','S',0};
if (!(ret = heap_alloc_zero(sizeof(CHMInfo))))
if (!(ret = calloc(1, sizeof(CHMInfo))))
return NULL;
ret->codePage = CP_ACP;
if (!(ret->szFile = strdupW(szFile))) {
heap_free(ret);
if (!(ret->szFile = wcsdup(szFile))) {
free(ret);
return NULL;
}
......@@ -682,17 +677,17 @@ CHMInfo *CloseCHM(CHMInfo *chm)
DWORD i;
for(i=0; i<chm->strings_size; i++)
heap_free(chm->strings[i]);
free(chm->strings[i]);
}
heap_free(chm->strings);
heap_free(chm->defWindow);
heap_free(chm->defTitle);
heap_free(chm->defTopic);
heap_free(chm->defToc);
heap_free(chm->szFile);
heap_free(chm->compiledFile);
heap_free(chm);
free(chm->strings);
free(chm->defWindow);
free(chm->defTitle);
free(chm->defTopic);
free(chm->defToc);
free(chm->szFile);
free(chm->compiledFile);
free(chm);
return NULL;
}
......@@ -41,10 +41,10 @@ static void free_content_item(ContentItem *item)
free_content_item(item->child);
heap_free(item->name);
heap_free(item->local);
heap_free(item->merge.chm_file);
heap_free(item->merge.chm_index);
free(item->name);
free(item->local);
free(item->merge.chm_file);
free(item->merge.chm_index);
item = next;
}
......@@ -97,7 +97,7 @@ static void parse_obj_node_param(ContentItem *item, ContentItem *hhc_root, const
if(param == &merge) {
SetChmPath(&item->merge, hhc_root->merge.chm_file, merge);
heap_free(merge);
free(merge);
}
}
......@@ -141,7 +141,7 @@ static ContentItem *parse_sitemap_object(HHInfo *info, stream_t *stream, Content
strbuf_init(&node);
strbuf_init(&node_name);
item = heap_alloc_zero(sizeof(ContentItem));
item = calloc(1, sizeof(ContentItem));
while(next_node(stream, &node)) {
get_node_name(&node, &node_name);
......@@ -306,7 +306,7 @@ void InitContent(HHInfo *info)
IStream *stream;
insert_type_t insert_type;
info->content = heap_alloc_zero(sizeof(ContentItem));
info->content = calloc(1, sizeof(ContentItem));
SetChmPath(&info->content->merge, info->pCHMInfo->szFile, info->WinType.pszToc);
stream = GetChmStream(info->pCHMInfo, info->pCHMInfo->szFile, &info->content->merge);
......
......@@ -179,7 +179,7 @@ static LPWSTR HH_LoadString(DWORD dwID)
iSize = LoadStringW(hhctrl_hinstance, dwID, (LPWSTR)&stringresource, 0);
string = heap_alloc((iSize + 2) * sizeof(WCHAR)); /* some strings (tab text) needs double-null termination */
string = malloc((iSize + 2) * sizeof(WCHAR)); /* some strings (tab text) needs double-null termination */
memcpy(string, stringresource, iSize*sizeof(WCHAR));
string[iSize] = 0;
......@@ -225,8 +225,8 @@ BOOL NavigateToUrl(HHInfo *info, LPCWSTR surl)
SetChmPath(&chm_path, info->pCHMInfo->szFile, surl);
ret = NavigateToChm(info, chm_path.chm_file, chm_path.chm_index);
heap_free(chm_path.chm_file);
heap_free(chm_path.chm_index);
free(chm_path.chm_file);
free(chm_path.chm_index);
return ret;
}
......@@ -844,7 +844,7 @@ static void DisplayPopupMenu(HHInfo *info)
item.dwTypeData = HH_LoadString(IDS_HIDETABS);
SetMenuItemInfoW(submenu, IDTB_EXPAND, FALSE, &item);
heap_free(item.dwTypeData);
free(item.dwTypeData);
/* Find the index toolbar button */
button.cbSize = sizeof(TBBUTTONINFOW);
......@@ -1029,7 +1029,7 @@ static BOOL HH_AddToolbar(HHInfo *pHHInfo)
szBuf[dwLen + 1] = 0; /* Double-null terminate */
buttons[dwIndex].iString = (DWORD)SendMessageW(hToolbar, TB_ADDSTRINGW, 0, (LPARAM)szBuf);
heap_free(szBuf);
free(szBuf);
}
SendMessageW(hToolbar, TB_ADDBUTTONSW, dwNumButtons, (LPARAM)buttons);
......@@ -1075,7 +1075,7 @@ static DWORD NP_CreateTab(HINSTANCE hInstance, HWND hwndTabCtrl, DWORD index)
ret = SendMessageW( hwndTabCtrl, TCM_INSERTITEMW, index, (LPARAM)&tie );
heap_free(tabText);
free(tabText);
return ret;
}
......@@ -1760,31 +1760,31 @@ static BOOL CreateViewer(HHInfo *pHHInfo)
void wintype_stringsW_free(struct wintype_stringsW *stringsW)
{
heap_free(stringsW->pszType);
heap_free(stringsW->pszCaption);
heap_free(stringsW->pszToc);
heap_free(stringsW->pszIndex);
heap_free(stringsW->pszFile);
heap_free(stringsW->pszHome);
heap_free(stringsW->pszJump1);
heap_free(stringsW->pszJump2);
heap_free(stringsW->pszUrlJump1);
heap_free(stringsW->pszUrlJump2);
free(stringsW->pszType);
free(stringsW->pszCaption);
free(stringsW->pszToc);
free(stringsW->pszIndex);
free(stringsW->pszFile);
free(stringsW->pszHome);
free(stringsW->pszJump1);
free(stringsW->pszJump2);
free(stringsW->pszUrlJump1);
free(stringsW->pszUrlJump2);
}
void wintype_stringsA_free(struct wintype_stringsA *stringsA)
{
heap_free(stringsA->pszType);
heap_free(stringsA->pszCaption);
heap_free(stringsA->pszToc);
heap_free(stringsA->pszIndex);
heap_free(stringsA->pszFile);
heap_free(stringsA->pszHome);
heap_free(stringsA->pszJump1);
heap_free(stringsA->pszJump2);
heap_free(stringsA->pszUrlJump1);
heap_free(stringsA->pszUrlJump2);
heap_free(stringsA->pszCustomTabs);
free(stringsA->pszType);
free(stringsA->pszCaption);
free(stringsA->pszToc);
free(stringsA->pszIndex);
free(stringsA->pszFile);
free(stringsA->pszHome);
free(stringsA->pszJump1);
free(stringsA->pszJump2);
free(stringsA->pszUrlJump1);
free(stringsA->pszUrlJump2);
free(stringsA->pszCustomTabs);
}
void ReleaseHelpViewer(HHInfo *info)
......@@ -1812,7 +1812,7 @@ void ReleaseHelpViewer(HHInfo *info)
if(info->WinType.hwndHelp)
DestroyWindow(info->WinType.hwndHelp);
heap_free(info);
free(info);
OleUninitialize();
}
......@@ -1823,7 +1823,7 @@ HHInfo *CreateHelpViewer(HHInfo *info, LPCWSTR filename, HWND caller)
if(!info)
{
info = heap_alloc_zero(sizeof(HHInfo));
info = calloc(1, sizeof(HHInfo));
list_add_tail(&window_list, &info->entry);
}
......@@ -1894,7 +1894,7 @@ WCHAR *decode_html(const char *html_fragment, int html_fragment_len, UINT code_p
int len, tmp_len = 0;
WCHAR *unicode_text;
tmp = heap_alloc(html_fragment_len+1);
tmp = malloc(html_fragment_len + 1);
while(1)
{
symbol = 0;
......@@ -1945,9 +1945,9 @@ WCHAR *decode_html(const char *html_fragment, int html_fragment_len, UINT code_p
tmp[tmp_len++] = 0; /* NULL-terminate the string */
len = MultiByteToWideChar(code_page, 0, tmp, tmp_len, NULL, 0);
unicode_text = heap_alloc(len*sizeof(WCHAR));
unicode_text = malloc(len * sizeof(WCHAR));
MultiByteToWideChar(code_page, 0, tmp, tmp_len, unicode_text, len);
heap_free(tmp);
free(tmp);
return unicode_text;
}
......
......@@ -116,7 +116,7 @@ static BOOL resolve_filename(const WCHAR *env_filename, WCHAR *fullname, DWORD b
if (!env_len)
return 0;
filename = heap_alloc(env_len * sizeof(WCHAR));
filename = malloc(env_len * sizeof(WCHAR));
if (filename == NULL)
return 0;
......@@ -127,7 +127,7 @@ static BOOL resolve_filename(const WCHAR *env_filename, WCHAR *fullname, DWORD b
{
*extra = 0;
if (window)
*window = strdupW(extra+1);
*window = wcsdup(extra + 1);
}
extra = wcsstr(filename, delimW);
......@@ -135,7 +135,7 @@ static BOOL resolve_filename(const WCHAR *env_filename, WCHAR *fullname, DWORD b
{
*extra = 0;
if (index)
*index = strdupW(extra+2);
*index = wcsdup(extra + 2);
}
GetFullPathNameW(filename, buflen, fullname, NULL);
......@@ -146,7 +146,7 @@ static BOOL resolve_filename(const WCHAR *env_filename, WCHAR *fullname, DWORD b
lstrcatW(fullname, filename);
}
heap_free(filename);
free(filename);
return (GetFileAttributesW(fullname) != INVALID_FILE_ATTRIBUTES);
}
......@@ -192,8 +192,8 @@ HWND WINAPI HtmlHelpW(HWND caller, LPCWSTR filename, UINT command, DWORD_PTR dat
info = CreateHelpViewer(info, fullname, caller);
if(!info)
{
heap_free(default_index);
heap_free(window);
free(default_index);
free(window);
return NULL;
}
......@@ -202,7 +202,7 @@ HWND WINAPI HtmlHelpW(HWND caller, LPCWSTR filename, UINT command, DWORD_PTR dat
if(!info->WinType.pszType)
info->WinType.pszType = info->stringsW.pszType = window;
else
heap_free(window);
free(window);
/* called to load a specified topic */
switch(command)
......@@ -228,7 +228,7 @@ HWND WINAPI HtmlHelpW(HWND caller, LPCWSTR filename, UINT command, DWORD_PTR dat
}
res = NavigateToChm(info, info->pCHMInfo->szFile, index);
heap_free(default_index);
free(default_index);
if(!res)
{
......@@ -281,14 +281,14 @@ HWND WINAPI HtmlHelpW(HWND caller, LPCWSTR filename, UINT command, DWORD_PTR dat
info = CreateHelpViewer(info, fullname, caller);
if(!info)
{
heap_free(window);
free(window);
return NULL;
}
if(!info->WinType.pszType)
info->WinType.pszType = info->stringsW.pszType = window;
else
heap_free(window);
free(window);
url = FindContextAlias(info->pCHMInfo, data);
if(!url)
......@@ -300,7 +300,7 @@ HWND WINAPI HtmlHelpW(HWND caller, LPCWSTR filename, UINT command, DWORD_PTR dat
}
NavigateToUrl(info, url);
heap_free(url);
free(url);
return info->WinType.hwndHelp;
}
case HH_PRETRANSLATEMESSAGE: {
......@@ -329,7 +329,7 @@ HWND WINAPI HtmlHelpW(HWND caller, LPCWSTR filename, UINT command, DWORD_PTR dat
HHInfo *info = NULL;
if (!filename && wintype->pszType)
window = strdupW(wintype->pszType);
window = wcsdup(wintype->pszType);
else if (!filename || !resolve_filename(filename, fullname, MAX_PATH, NULL, &window) || !window)
{
WARN("can't find window name: %s\n", debugstr_w(filename));
......@@ -338,12 +338,12 @@ HWND WINAPI HtmlHelpW(HWND caller, LPCWSTR filename, UINT command, DWORD_PTR dat
info = find_window(window);
if (!info)
{
info = heap_alloc_zero(sizeof(HHInfo));
info = calloc(1, sizeof(HHInfo));
info->WinType.pszType = info->stringsW.pszType = window;
list_add_tail(&window_list, &info->entry);
}
else
heap_free(window);
free(window);
TRACE("Changing WINTYPE, fsValidMembers=0x%lx\n", wintype->fsValidMembers);
......@@ -365,13 +365,13 @@ HWND WINAPI HtmlHelpW(HWND caller, LPCWSTR filename, UINT command, DWORD_PTR dat
if (!info)
{
WARN("Could not find window named %s.\n", debugstr_w(window));
heap_free(window);
free(window);
return (HWND)~0;
}
TRACE("Retrieving WINTYPE for %s.\n", debugstr_w(window));
*wintype = info->WinType;
heap_free(window);
free(window);
return 0;
}
default:
......@@ -468,7 +468,7 @@ HWND WINAPI HtmlHelpA(HWND caller, LPCSTR filename, UINT command, DWORD_PTR data
{
WCHAR *wdata = strdupAtoW( (const char *)data );
result = HtmlHelpW( caller, wfile, command, (DWORD_PTR)wdata );
heap_free(wdata);
free(wdata);
goto done;
}
......@@ -490,7 +490,7 @@ HWND WINAPI HtmlHelpA(HWND caller, LPCSTR filename, UINT command, DWORD_PTR data
result = HtmlHelpW( caller, wfile, command, data );
done:
heap_free(wfile);
free(wfile);
return result;
}
......@@ -553,7 +553,7 @@ int WINAPI doWinMain(HINSTANCE hInstance, LPSTR szCmdLine)
return 0;
buflen = MultiByteToWideChar(CP_ACP, 0, szCmdLine, len, NULL, 0) + 1;
filename = heap_alloc(buflen * sizeof(WCHAR));
filename = malloc(buflen * sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, szCmdLine, len, filename, buflen);
filename[buflen-1] = 0;
......@@ -563,7 +563,7 @@ int WINAPI doWinMain(HINSTANCE hInstance, LPSTR szCmdLine)
else
hwnd = HtmlHelpW(GetDesktopWindow(), filename, HH_DISPLAY_TOPIC, 0);
heap_free(filename);
free(filename);
if (!hwnd)
{
......
......@@ -40,7 +40,6 @@
#endif
#include "wine/itss.h"
#include "wine/heap.h"
#include "wine/list.h"
#define WB_GOBACK 0
......@@ -245,26 +244,6 @@ HHInfo *find_window(const WCHAR *window) DECLSPEC_HIDDEN;
/* memory allocation functions */
static inline void * __WINE_ALLOC_SIZE(2) heap_realloc_zero(void *mem, size_t len)
{
return HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, len);
}
static inline LPWSTR strdupW(LPCWSTR str)
{
LPWSTR ret;
int size;
if(!str)
return NULL;
size = (lstrlenW(str)+1)*sizeof(WCHAR);
ret = heap_alloc(size);
memcpy(ret, str, size);
return ret;
}
static inline LPWSTR strdupnAtoW(LPCSTR str, LONG lenA)
{
LPWSTR ret;
......@@ -281,7 +260,7 @@ static inline LPWSTR strdupnAtoW(LPCSTR str, LONG lenA)
}
len = MultiByteToWideChar(CP_ACP, 0, str, lenA, NULL, 0)+1; /* +1 for null pad */
ret = heap_alloc(len*sizeof(WCHAR));
ret = malloc(len * sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, str, lenA, ret, len);
ret[len-1] = 0;
......@@ -302,7 +281,7 @@ static inline LPSTR strdupWtoA(LPCWSTR str)
return NULL;
len = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
ret = heap_alloc(len);
ret = malloc(len);
WideCharToMultiByte(CP_ACP, 0, str, -1, ret, len, NULL, NULL);
return ret;
}
......
......@@ -54,7 +54,7 @@ static void fill_index_tree(HWND hwnd, IndexItem *item)
static void item_realloc(IndexItem *item, int num_items)
{
item->nItems = num_items;
item->items = heap_realloc(item->items, sizeof(IndexSubItem)*item->nItems);
item->items = realloc(item->items, sizeof(IndexSubItem) * item->nItems);
item->items[item->nItems-1].name = NULL;
item->items[item->nItems-1].local = NULL;
item->itemFlags = 0x00;
......@@ -127,9 +127,9 @@ static IndexItem *parse_index_sitemap_object(HHInfo *info, stream_t *stream)
strbuf_init(&node);
strbuf_init(&node_name);
item = heap_alloc_zero(sizeof(IndexItem));
item = calloc(1, sizeof(IndexItem));
item->nItems = 0;
item->items = heap_alloc_zero(0);
item->items = calloc(2, sizeof(void *));
item->itemFlags = 0x11;
while(next_node(stream, &node)) {
......@@ -237,9 +237,9 @@ static void parse_hhindex(HHInfo *info, IStream *str, IndexItem *item)
item_realloc(item, num_items+1);
memcpy(&item->items[num_items], &new_item->items[0], sizeof(IndexSubItem));
heap_free(new_item->keyword);
heap_free(new_item->items);
heap_free(new_item);
free(new_item->keyword);
free(new_item->items);
free(new_item);
} else if(new_item) {
item->next = new_item;
item->next->merge = item->merge;
......@@ -266,7 +266,7 @@ void InitIndex(HHInfo *info)
{
IStream *stream;
info->index = heap_alloc_zero(sizeof(IndexItem));
info->index = calloc(1, sizeof(IndexItem));
info->index->nItems = 0;
SetChmPath(&info->index->merge, info->pCHMInfo->szFile, info->WinType.pszIndex);
......@@ -292,17 +292,17 @@ void ReleaseIndex(HHInfo *info)
if(!item) return;
/* Note: item->merge is identical for all items, only free once */
heap_free(item->merge.chm_file);
heap_free(item->merge.chm_index);
free(item->merge.chm_file);
free(item->merge.chm_index);
while(item) {
next = item->next;
heap_free(item->keyword);
free(item->keyword);
for(i=0;i<item->nItems;i++) {
heap_free(item->items[i].name);
heap_free(item->items[i].local);
free(item->items[i].name);
free(item->items[i].local);
}
heap_free(item->items);
free(item->items);
item = next;
}
......
......@@ -32,10 +32,10 @@ static SearchItem *alloc_search_item(WCHAR *title, const WCHAR *filename)
int filename_len = filename ? (lstrlenW(filename)+1)*sizeof(WCHAR) : 0;
SearchItem *item;
item = heap_alloc_zero(sizeof(SearchItem));
item = calloc(1, sizeof(SearchItem));
if(filename)
{
item->filename = heap_alloc(filename_len);
item->filename = malloc(filename_len);
memcpy(item->filename, filename, filename_len);
}
item->title = title; /* Already allocated */
......@@ -72,7 +72,7 @@ static void fill_search_tree(HWND hwndList, SearchItem *item)
*/
static WCHAR *SearchCHM_File(IStorage *pStorage, const WCHAR *file, const char *needle)
{
char *buffer = heap_alloc(BLOCK_SIZE);
char *buffer = malloc(BLOCK_SIZE);
strbuf_t content, node, node_name;
IStream *temp_stream = NULL;
DWORD i, buffer_size = 0;
......@@ -105,12 +105,12 @@ static WCHAR *SearchCHM_File(IStorage *pStorage, const WCHAR *file, const char *
if(!stricmp(node_name.buf, "title"))
{
int wlen = MultiByteToWideChar(CP_ACP, 0, text, textlen, NULL, 0);
title = heap_alloc((wlen+1)*sizeof(WCHAR));
title = malloc((wlen + 1) * sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, text, textlen, title, wlen);
title[wlen] = 0;
}
buffer = heap_realloc(buffer, buffer_size + textlen + 1);
buffer = realloc(buffer, buffer_size + textlen + 1);
memcpy(&buffer[buffer_size], text, textlen);
buffer[buffer_size + textlen] = '\0';
buffer_size += textlen;
......@@ -135,12 +135,12 @@ static WCHAR *SearchCHM_File(IStorage *pStorage, const WCHAR *file, const char *
strbuf_free(&node_name);
cleanup:
heap_free(buffer);
free(buffer);
if(temp_stream)
IStream_Release(temp_stream);
if(!found)
{
heap_free(title);
free(title);
return NULL;
}
return title;
......@@ -238,7 +238,7 @@ void ReleaseSearch(HHInfo *info)
info->search.root = NULL;
while(item) {
heap_free(item->filename);
free(item->filename);
item = item->next;
}
}
......@@ -27,7 +27,7 @@ void strbuf_init(strbuf_t *buf)
{
buf->size = 8;
buf->len = 0;
buf->buf = heap_alloc(buf->size);
buf->buf = malloc(buf->size);
}
void strbuf_zero(strbuf_t *buf)
......@@ -37,14 +37,14 @@ void strbuf_zero(strbuf_t *buf)
void strbuf_free(strbuf_t *buf)
{
heap_free(buf->buf);
free(buf->buf);
}
static void strbuf_append(strbuf_t *buf, const char *data, int len)
{
if(buf->len+len > buf->size) {
buf->size = buf->len+len;
buf->buf = heap_realloc(buf->buf, buf->size);
buf->buf = realloc(buf->buf, buf->size);
}
memcpy(buf->buf+buf->len, data, len);
......@@ -169,7 +169,7 @@ const char *get_attr(const char *node, const char *name, int *len)
/* Create a lower case copy of the node */
node_len = strlen(node)+1;
node_buf = heap_alloc(node_len*sizeof(char));
node_buf = malloc(node_len * sizeof(char));
if(!node_buf)
return NULL;
memcpy(node_buf, node, node_len);
......@@ -187,7 +187,7 @@ const char *get_attr(const char *node, const char *name, int *len)
ptr = strstr(node_buf, name_buf);
if(!ptr) {
WARN("name not found\n");
heap_free(node_buf);
free(node_buf);
return NULL;
}
......@@ -195,7 +195,7 @@ const char *get_attr(const char *node, const char *name, int *len)
ptr2 = strchr(ptr, '\"');
if(!ptr2)
{
heap_free(node_buf);
free(node_buf);
return NULL;
}
......@@ -203,6 +203,6 @@ const char *get_attr(const char *node, const char *name, int *len)
/* Return the pointer offset within the original string */
ptr = node+(ptr-node_buf);
heap_free(node_buf);
free(node_buf);
return ptr;
}
......@@ -81,7 +81,7 @@ static ULONG STDMETHODCALLTYPE Site_Release(IOleClientSite *iface)
IOleObject_Release(This->ole_obj);
if(This->web_browser)
IWebBrowser2_Release(This->web_browser);
heap_free(This);
free(This);
}
return ref;
......@@ -674,7 +674,7 @@ BOOL InitWebBrowser(HHInfo *info, HWND hwndParent)
HRESULT hr;
RECT rc;
container = heap_alloc_zero(sizeof(*container));
container = calloc(1, sizeof(*container));
if (!container)
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