Commit 03218d6d authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

urlmon: Wrap heap functions.

parent 63fe32a8
......@@ -132,7 +132,7 @@ static ULONG WINAPI BindStatusCallback_Release(IBindStatusCallback *iface)
if(This->authenticate)
IAuthenticate_Release(This->authenticate);
IBindStatusCallback_Release(This->callback);
HeapFree(GetProcessHeap(), 0, This);
urlmon_free(This);
}
return ref;
......@@ -455,7 +455,7 @@ static const IAuthenticateVtbl BSCAuthenticateVtbl = {
static IBindStatusCallback *create_bsc(IBindStatusCallback *bsc)
{
BindStatusCallback *ret = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(BindStatusCallback));
BindStatusCallback *ret = urlmon_alloc_zero(sizeof(BindStatusCallback));
ret->lpBindStatusCallbackVtbl = &BindStatusCallbackVtbl;
ret->lpServiceProviderVtbl = &BSCServiceProviderVtbl;
......@@ -640,7 +640,7 @@ static ULONG WINAPI AsyncBindCtx_Release(IBindCtx *iface)
if(!ref) {
IBindCtx_Release(This->bindctx);
HeapFree(GetProcessHeap(), 0, This);
urlmon_free(This);
}
return ref;
......@@ -837,7 +837,7 @@ HRESULT WINAPI CreateAsyncBindCtxEx(IBindCtx *ibind, DWORD options,
if(FAILED(hres))
return hres;
ret = HeapAlloc(GetProcessHeap(), 0, sizeof(AsyncBindCtx));
ret = urlmon_alloc(sizeof(AsyncBindCtx));
ret->lpBindCtxVtbl = &AsyncBindCtxVtbl;
ret->ref = 1;
......
......@@ -299,7 +299,7 @@ static ULONG WINAPI ProtocolStream_Release(IStream *iface)
if(!ref) {
IInternetProtocol_Release(This->protocol);
HeapFree(GetProcessHeap(), 0, This);
urlmon_free(This);
URLMON_UnlockModule();
}
......@@ -451,7 +451,7 @@ static const IStreamVtbl ProtocolStreamVtbl = {
static ProtocolStream *create_stream(IInternetProtocol *protocol)
{
ProtocolStream *ret = HeapAlloc(GetProcessHeap(), 0, sizeof(ProtocolStream));
ProtocolStream *ret = urlmon_alloc(sizeof(ProtocolStream));
ret->lpStreamVtbl = &ProtocolStreamVtbl;
ret->ref = 1;
......@@ -531,10 +531,10 @@ static ULONG WINAPI Binding_Release(IBinding *iface)
ReleaseBindInfo(&This->bindinfo);
This->section.DebugInfo->Spare[0] = 0;
DeleteCriticalSection(&This->section);
HeapFree(GetProcessHeap(), 0, This->mime);
HeapFree(GetProcessHeap(), 0, This->url);
urlmon_free(This->mime);
urlmon_free(This->url);
HeapFree(GetProcessHeap(), 0, This);
urlmon_free(This);
URLMON_UnlockModule();
}
......@@ -631,7 +631,7 @@ static void switch_proc(Binding *binding, task_header_t *t)
IInternetProtocol_Continue(binding->protocol, &task->data);
HeapFree(GetProcessHeap(), 0, task);
urlmon_free(task);
}
static HRESULT WINAPI InternetProtocolSink_Switch(IInternetProtocolSink *iface,
......@@ -642,7 +642,7 @@ static HRESULT WINAPI InternetProtocolSink_Switch(IInternetProtocolSink *iface,
TRACE("(%p)->(%p)\n", This, pProtocolData);
task = HeapAlloc(GetProcessHeap(), 0, sizeof(switch_task_t));
task = urlmon_alloc(sizeof(switch_task_t));
memcpy(&task->data, pProtocolData, sizeof(PROTOCOLDATA));
push_task(This, &task->header, switch_proc);
......@@ -670,8 +670,8 @@ static void on_progress_proc(Binding *binding, task_header_t *t)
IBindStatusCallback_OnProgress(binding->callback, task->progress,
task->progress_max, task->status_code, task->status_text);
HeapFree(GetProcessHeap(), 0, task->status_text);
HeapFree(GetProcessHeap(), 0, task);
urlmon_free(task->status_text);
urlmon_free(task);
}
static void on_progress(Binding *This, ULONG progress, ULONG progress_max,
......@@ -685,7 +685,7 @@ static void on_progress(Binding *This, ULONG progress, ULONG progress_max,
return;
}
task = HeapAlloc(GetProcessHeap(), 0, sizeof(on_progress_task_t));
task = urlmon_alloc(sizeof(on_progress_task_t));
task->progress = progress;
task->progress_max = progress_max;
......@@ -694,7 +694,7 @@ static void on_progress(Binding *This, ULONG progress, ULONG progress_max,
if(status_text) {
DWORD size = (strlenW(status_text)+1)*sizeof(WCHAR);
task->status_text = HeapAlloc(GetProcessHeap(), 0, size);
task->status_text = urlmon_alloc(size);
memcpy(task->status_text, status_text, size);
}else {
task->status_text = NULL;
......@@ -727,7 +727,7 @@ static HRESULT WINAPI InternetProtocolSink_ReportProgress(IInternetProtocolSink
break;
case BINDSTATUS_MIMETYPEAVAILABLE: {
int len = strlenW(szStatusText)+1;
This->mime = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
This->mime = urlmon_alloc(len*sizeof(WCHAR));
memcpy(This->mime, szStatusText, len*sizeof(WCHAR));
break;
}
......@@ -822,7 +822,7 @@ static void report_data_proc(Binding *binding, task_header_t *t)
report_data(binding, task->bscf, task->progress, task->progress_max);
HeapFree(GetProcessHeap(), 0, task);
urlmon_free(task);
}
static HRESULT WINAPI InternetProtocolSink_ReportData(IInternetProtocolSink *iface,
......@@ -836,7 +836,7 @@ static HRESULT WINAPI InternetProtocolSink_ReportData(IInternetProtocolSink *ifa
FIXME("called from worked hread\n");
if(This->continue_call) {
report_data_task_t *task = HeapAlloc(GetProcessHeap(), 0, sizeof(report_data_task_t));
report_data_task_t *task = urlmon_alloc(sizeof(report_data_task_t));
task->bscf = grfBSCF;
task->progress = ulProgress;
task->progress_max = ulProgressMax;
......@@ -858,7 +858,7 @@ static void report_result_proc(Binding *binding, task_header_t *t)
binding->request_locked = FALSE;
}
HeapFree(GetProcessHeap(), 0, t);
urlmon_free(t);
}
static HRESULT WINAPI InternetProtocolSink_ReportResult(IInternetProtocolSink *iface,
......@@ -871,7 +871,7 @@ static HRESULT WINAPI InternetProtocolSink_ReportResult(IInternetProtocolSink *i
if(GetCurrentThreadId() == This->apartment_thread && !This->continue_call) {
IInternetProtocol_Terminate(This->protocol, 0);
}else {
task_header_t *task = HeapAlloc(GetProcessHeap(), 0, sizeof(task_header_t));
task_header_t *task = urlmon_alloc(sizeof(task_header_t));
push_task(This, task, report_result_proc);
}
......@@ -1123,7 +1123,7 @@ static HRESULT Binding_Create(LPCWSTR url, IBindCtx *pbc, REFIID riid, Binding *
URLMON_LockModule();
ret = HeapAlloc(GetProcessHeap(), 0, sizeof(Binding));
ret = urlmon_alloc(sizeof(Binding));
ret->lpBindingVtbl = &BindingVtbl;
ret->lpInternetProtocolSinkVtbl = &InternetProtocolSinkVtbl;
......@@ -1185,7 +1185,7 @@ static HRESULT Binding_Create(LPCWSTR url, IBindCtx *pbc, REFIID riid, Binding *
ret->bindf |= BINDF_NEEDFILE;
len = strlenW(url)+1;
ret->url = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
ret->url = urlmon_alloc(len*sizeof(WCHAR));
memcpy(ret->url, url, len*sizeof(WCHAR));
ret->stream = create_stream(ret->protocol);
......
......@@ -114,7 +114,7 @@ static ULONG WINAPI BindProtocol_Release(IInternetProtocol *iface)
if(This->protocol_sink)
IInternetProtocolSink_Release(This->protocol_sink);
HeapFree(GetProcessHeap(), 0, This);
urlmon_free(This);
URLMON_UnlockModule();
}
......@@ -480,7 +480,7 @@ static const IInternetProtocolSinkVtbl InternetProtocolSinkVtbl = {
HRESULT create_binding_protocol(LPCWSTR url, IInternetProtocol **protocol)
{
BindProtocol *ret = HeapAlloc(GetProcessHeap(), 0, sizeof(BindProtocol));
BindProtocol *ret = urlmon_alloc(sizeof(BindProtocol));
ret->lpInternetProtocolVtbl = &BindProtocolVtbl;
ret->lpInternetBindInfoVtbl = &InternetBindInfoVtbl;
......
......@@ -92,7 +92,7 @@ static ULONG WINAPI FileProtocol_Release(IInternetProtocol *iface)
if(!ref) {
if(This->file)
CloseHandle(This->file);
HeapFree(GetProcessHeap(), 0, This);
urlmon_free(This);
URLMON_UnlockModule();
}
......@@ -135,10 +135,10 @@ static HRESULT WINAPI FileProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl
return MK_E_SYNTAX;
len = lstrlenW(szUrl)+16;
url = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
url = urlmon_alloc(len*sizeof(WCHAR));
hres = CoInternetParseUrl(szUrl, PARSE_ENCODE, 0, url, len, &len, 0);
if(FAILED(hres)) {
HeapFree(GetProcessHeap(), 0, url);
urlmon_free(url);
return hres;
}
......@@ -163,7 +163,7 @@ static HRESULT WINAPI FileProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl
This->file = NULL;
IInternetProtocolSink_ReportResult(pOIProtSink, INET_E_RESOURCE_NOT_FOUND,
GetLastError(), NULL);
HeapFree(GetProcessHeap(), 0, url);
urlmon_free(url);
return INET_E_RESOURCE_NOT_FOUND;
}
......@@ -180,7 +180,7 @@ static HRESULT WINAPI FileProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl
}
}
HeapFree(GetProcessHeap(), 0, url);
urlmon_free(url);
if(GetFileSizeEx(This->file, &size))
IInternetProtocolSink_ReportData(pOIProtSink,
......@@ -353,7 +353,7 @@ HRESULT FileProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj)
URLMON_LockModule();
ret = HeapAlloc(GetProcessHeap(), 0, sizeof(FileProtocol));
ret = urlmon_alloc(sizeof(FileProtocol));
ret->lpInternetProtocolVtbl = &FileProtocolVtbl;
ret->lpInternetPriorityVtbl = &FilePriorityVtbl;
......
......@@ -78,8 +78,8 @@ static ULONG WINAPI EnumFORMATETC_Release(IEnumFORMATETC *iface)
TRACE("(%p) ref=%d\n", This, ref);
if(!ref) {
HeapFree(GetProcessHeap(), 0, This->fetc);
HeapFree(GetProcessHeap(), 0, This);
urlmon_free(This->fetc);
urlmon_free(This);
URLMON_UnlockModule();
}
......@@ -160,7 +160,7 @@ static const IEnumFORMATETCVtbl EnumFORMATETCVtbl = {
static IEnumFORMATETC *EnumFORMATETC_Create(UINT cfmtetc, const FORMATETC *rgfmtetc, UINT it)
{
EnumFORMATETC *ret = HeapAlloc(GetProcessHeap(), 0, sizeof(EnumFORMATETC));
EnumFORMATETC *ret = urlmon_alloc(sizeof(EnumFORMATETC));
URLMON_LockModule();
......@@ -169,7 +169,7 @@ static IEnumFORMATETC *EnumFORMATETC_Create(UINT cfmtetc, const FORMATETC *rgfmt
ret->it = it;
ret->fetc_cnt = cfmtetc;
ret->fetc = HeapAlloc(GetProcessHeap(), 0, cfmtetc*sizeof(FORMATETC));
ret->fetc = urlmon_alloc(cfmtetc*sizeof(FORMATETC));
memcpy(ret->fetc, rgfmtetc, cfmtetc*sizeof(FORMATETC));
return (IEnumFORMATETC*)ret;
......
......@@ -81,7 +81,7 @@ static ULONG WINAPI FtpProtocol_Release(IInternetProtocol *iface)
TRACE("(%p) ref=%d\n", This, ref);
if(!ref) {
HeapFree(GetProcessHeap(), 0, This);
urlmon_free(This);
URLMON_UnlockModule();
}
......@@ -191,7 +191,7 @@ HRESULT FtpProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj)
URLMON_LockModule();
ret = HeapAlloc(GetProcessHeap(), 0, sizeof(FtpProtocol));
ret = urlmon_alloc(sizeof(FtpProtocol));
ret->lpInternetProtocolVtbl = &FtpProtocolVtbl;
ret->ref = 1;
......
......@@ -159,7 +159,7 @@ static void HTTPPROTOCOL_Close(HttpProtocol *This)
if (This->full_header)
{
if (This->full_header != wszHeaders)
HeapFree(GetProcessHeap(), 0, This->full_header);
urlmon_free(This->full_header);
This->full_header = 0;
}
This->flags = 0;
......@@ -234,7 +234,7 @@ static inline LPWSTR strndupW(LPCWSTR string, int len)
{
LPWSTR ret = NULL;
if (string &&
(ret = HeapAlloc(GetProcessHeap(), 0, (len+1)*sizeof(WCHAR))) != NULL)
(ret = urlmon_alloc((len+1)*sizeof(WCHAR))) != NULL)
{
memcpy(ret, string, len*sizeof(WCHAR));
ret[len] = 0;
......@@ -296,7 +296,7 @@ static ULONG WINAPI HttpProtocol_Release(IInternetProtocol *iface)
if(!ref) {
HTTPPROTOCOL_Close(This);
HeapFree(GetProcessHeap(), 0, This);
urlmon_free(This);
URLMON_UnlockModule();
}
......@@ -378,7 +378,7 @@ static HRESULT WINAPI HttpProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl
{
WARN("ObtainUserAgentString failed: %08x\n", hres);
}
else if (!(user_agenta = HeapAlloc(GetProcessHeap(), 0, len*sizeof(CHAR))))
else if (!(user_agenta = urlmon_alloc(len*sizeof(CHAR))))
{
WARN("Out of memory\n");
}
......@@ -393,7 +393,7 @@ static HRESULT WINAPI HttpProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl
else
MultiByteToWideChar(CP_ACP, 0, user_agenta, -1, user_agent, len*sizeof(WCHAR));
}
HeapFree(GetProcessHeap(), 0, user_agenta);
urlmon_free(user_agenta);
}
This->internet = InternetOpenW(user_agent, 0, NULL, NULL, INTERNET_FLAG_ASYNC);
......@@ -472,8 +472,7 @@ static HRESULT WINAPI HttpProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl
else
{
int len_addl_header = lstrlenW(addl_header);
This->full_header = HeapAlloc(GetProcessHeap(), 0,
len_addl_header*sizeof(WCHAR)+sizeof(wszHeaders));
This->full_header = urlmon_alloc(len_addl_header*sizeof(WCHAR)+sizeof(wszHeaders));
if (!This->full_header)
{
WARN("Out of memory\n");
......@@ -557,10 +556,10 @@ done:
CoTaskMemFree(accept_mimes[num++]);
CoTaskMemFree(user_agent);
HeapFree(GetProcessHeap(), 0, pass);
HeapFree(GetProcessHeap(), 0, user);
HeapFree(GetProcessHeap(), 0, path);
HeapFree(GetProcessHeap(), 0, host);
urlmon_free(pass);
urlmon_free(user);
urlmon_free(path);
urlmon_free(host);
return hres;
}
......@@ -610,7 +609,7 @@ static HRESULT WINAPI HttpProtocol_Continue(IInternetProtocol *iface, PROTOCOLDA
if ((!HttpQueryInfoW(This->request, HTTP_QUERY_RAW_HEADERS_CRLF, response_headers, &len,
NULL) &&
GetLastError() != ERROR_INSUFFICIENT_BUFFER) ||
!(response_headers = HeapAlloc(GetProcessHeap(), 0, len)) ||
!(response_headers = urlmon_alloc(len)) ||
!HttpQueryInfoW(This->request, HTTP_QUERY_RAW_HEADERS_CRLF, response_headers, &len,
NULL))
{
......@@ -631,7 +630,7 @@ static HRESULT WINAPI HttpProtocol_Continue(IInternetProtocol *iface, PROTOCOLDA
len = 0;
if ((!HttpQueryInfoW(This->request, HTTP_QUERY_CONTENT_TYPE, content_type, &len, NULL) &&
GetLastError() != ERROR_INSUFFICIENT_BUFFER) ||
!(content_type = HeapAlloc(GetProcessHeap(), 0, len)) ||
!(content_type = urlmon_alloc(len)) ||
!HttpQueryInfoW(This->request, HTTP_QUERY_CONTENT_TYPE, content_type, &len, NULL))
{
WARN("HttpQueryInfo failed: %d\n", GetLastError());
......@@ -657,7 +656,7 @@ static HRESULT WINAPI HttpProtocol_Continue(IInternetProtocol *iface, PROTOCOLDA
len = 0;
if ((!HttpQueryInfoW(This->request, HTTP_QUERY_CONTENT_LENGTH, content_length, &len, NULL) &&
GetLastError() != ERROR_INSUFFICIENT_BUFFER) ||
!(content_length = HeapAlloc(GetProcessHeap(), 0, len)) ||
!(content_length = urlmon_alloc(len)) ||
!HttpQueryInfoW(This->request, HTTP_QUERY_CONTENT_LENGTH, content_length, &len, NULL))
{
WARN("HttpQueryInfo failed: %d\n", GetLastError());
......@@ -694,9 +693,9 @@ static HRESULT WINAPI HttpProtocol_Continue(IInternetProtocol *iface, PROTOCOLDA
}
done:
HeapFree(GetProcessHeap(), 0, response_headers);
HeapFree(GetProcessHeap(), 0, content_type);
HeapFree(GetProcessHeap(), 0, content_length);
urlmon_free(response_headers);
urlmon_free(content_type);
urlmon_free(content_length);
/* Returns S_OK on native */
return S_OK;
......@@ -926,7 +925,7 @@ HRESULT HttpProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj)
URLMON_LockModule();
ret = HeapAlloc(GetProcessHeap(), 0, sizeof(HttpProtocol));
ret = urlmon_alloc(sizeof(HttpProtocol));
ret->lpInternetProtocolVtbl = &HttpProtocolVtbl;
ret->lpInternetPriorityVtbl = &HttpPriorityVtbl;
......
......@@ -88,7 +88,7 @@ static ULONG WINAPI MkProtocol_Release(IInternetProtocol *iface)
if(This->stream)
IStream_Release(This->stream);
HeapFree(GetProcessHeap(), 0, This);
urlmon_free(This);
URLMON_UnlockModule();
}
......@@ -153,11 +153,11 @@ static HRESULT WINAPI MkProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
if(!ptr)
return report_result(pOIProtSink, INET_E_RESOURCE_NOT_FOUND, ERROR_INVALID_PARAMETER);
progid = HeapAlloc(GetProcessHeap(), 0, (ptr-ptr2+1)*sizeof(WCHAR));
progid = urlmon_alloc((ptr-ptr2+1)*sizeof(WCHAR));
memcpy(progid, ptr2, (ptr-ptr2)*sizeof(WCHAR));
progid[ptr-ptr2] = 0;
hres = CLSIDFromProgID(progid, &clsid);
HeapFree(GetProcessHeap(), 0, progid);
urlmon_free(progid);
if(FAILED(hres))
return report_result(pOIProtSink, INET_E_RESOURCE_NOT_FOUND, ERROR_INVALID_PARAMETER);
......@@ -169,10 +169,10 @@ static HRESULT WINAPI MkProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
}
len = strlenW(--ptr2);
display_name = HeapAlloc(GetProcessHeap(), 0, (len+1)*sizeof(WCHAR));
display_name = urlmon_alloc((len+1)*sizeof(WCHAR));
memcpy(display_name, ptr2, (len+1)*sizeof(WCHAR));
hres = IParseDisplayName_ParseDisplayName(pdn, NULL /* FIXME */, display_name, &eaten, &mon);
HeapFree(GetProcessHeap(), 0, display_name);
urlmon_free(display_name);
IParseDisplayName_Release(pdn);
if(FAILED(hres)) {
WARN("ParseDisplayName failed: %08x\n", hres);
......@@ -307,7 +307,7 @@ HRESULT MkProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj)
URLMON_LockModule();
ret = HeapAlloc(GetProcessHeap(), 0, sizeof(MkProtocol));
ret = urlmon_alloc(sizeof(MkProtocol));
ret->lpInternetProtocolVtbl = &MkProtocolVtbl;
ret->ref = 1;
......
......@@ -550,7 +550,7 @@ static HRESULT register_inf(BOOL doregister)
INF_SET_CLSID(MkProtocol);
for(i = 0; i < sizeof(pse)/sizeof(pse[0]); i++) {
pse[i].pszValue = HeapAlloc(GetProcessHeap(), 0, 39);
pse[i].pszValue = urlmon_alloc(39);
sprintf(pse[i].pszValue, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
clsids[i]->Data1, clsids[i]->Data2, clsids[i]->Data3, clsids[i]->Data4[0],
clsids[i]->Data4[1], clsids[i]->Data4[2], clsids[i]->Data4[3], clsids[i]->Data4[4],
......@@ -566,7 +566,7 @@ static HRESULT register_inf(BOOL doregister)
hres = pRegInstall(URLMON_hInstance, doregister ? "RegisterDll" : "UnregisterDll", &strtable);
for(i=0; i < sizeof(pse)/sizeof(pse[0]); i++)
HeapFree(GetProcessHeap(), 0, pse[i].pszValue);
urlmon_free(pse[i].pszValue);
return hres;
}
......
......@@ -173,7 +173,7 @@ static ULONG WINAPI SecManagerImpl_Release(IInternetSecurityManager* iface)
if(This->custom_manager)
IInternetSecurityManager_Release(This->custom_manager);
HeapFree(GetProcessHeap(),0,This);
urlmon_free(This);
URLMON_UnlockModule();
}
......@@ -260,7 +260,7 @@ static HRESULT WINAPI SecManagerImpl_MapUrlToZone(IInternetSecurityManager *ifac
FIXME("not supported flags: %08x\n", dwFlags);
size = (strlenW(pwszUrl)+16) * sizeof(WCHAR);
url = HeapAlloc(GetProcessHeap(), 0, size);
url = urlmon_alloc(size);
hres = CoInternetParseUrl(pwszUrl, PARSE_SECURITY_URL, 0, url, size/sizeof(WCHAR), &size, 0);
if(FAILED(hres))
......@@ -268,7 +268,7 @@ static HRESULT WINAPI SecManagerImpl_MapUrlToZone(IInternetSecurityManager *ifac
hres = map_url_to_zone(url, pdwZone);
HeapFree(GetProcessHeap(), 0, url);
urlmon_free(url);
return hres;
}
......@@ -300,7 +300,7 @@ static HRESULT WINAPI SecManagerImpl_GetSecurityId(IInternetSecurityManager *ifa
FIXME("dwReserved is not supported\n");
len = strlenW(pwszUrl)+1;
buf = HeapAlloc(GetProcessHeap(), 0, (len+16)*sizeof(WCHAR));
buf = urlmon_alloc((len+16)*sizeof(WCHAR));
hres = CoInternetParseUrl(pwszUrl, PARSE_SECURITY_URL, 0, buf, len, &size, 0);
if(FAILED(hres))
......@@ -308,7 +308,7 @@ static HRESULT WINAPI SecManagerImpl_GetSecurityId(IInternetSecurityManager *ifa
hres = map_url_to_zone(buf, &zone);
if(FAILED(hres)) {
HeapFree(GetProcessHeap(), 0, buf);
urlmon_free(buf);
return hres == 0x80041001 ? E_INVALIDARG : hres;
}
......@@ -318,7 +318,7 @@ static HRESULT WINAPI SecManagerImpl_GetSecurityId(IInternetSecurityManager *ifa
static const BYTE secidFile[] = {'f','i','l','e',':'};
HeapFree(GetProcessHeap(), 0, buf);
urlmon_free(buf);
if(*pcbSecurityId < sizeof(secidFile)+sizeof(zone))
return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
......@@ -344,12 +344,12 @@ static HRESULT WINAPI SecManagerImpl_GetSecurityId(IInternetSecurityManager *ifa
len = WideCharToMultiByte(CP_ACP, 0, buf, -1, NULL, 0, NULL, NULL)-1;
if(len+sizeof(DWORD) > *pcbSecurityId) {
HeapFree(GetProcessHeap(), 0, buf);
urlmon_free(buf);
return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
}
WideCharToMultiByte(CP_ACP, 0, buf, -1, (LPSTR)pbSecurityId, -1, NULL, NULL);
HeapFree(GetProcessHeap(), 0, buf);
urlmon_free(buf);
*(DWORD*)(pbSecurityId+len) = zone;
......@@ -464,7 +464,7 @@ HRESULT SecManagerImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj)
SecManagerImpl *This;
TRACE("(%p,%p)\n",pUnkOuter,ppobj);
This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
This = urlmon_alloc(sizeof(*This));
/* Initialize the virtual function table. */
This->lpInternetSecurityManagerVtbl = &VT_SecManagerImpl;
......@@ -577,7 +577,7 @@ static ULONG WINAPI ZoneMgrImpl_Release(IInternetZoneManager* iface)
TRACE("(%p)->(ref before=%u)\n",This, refCount + 1);
if(!refCount) {
HeapFree(GetProcessHeap(), 0, This);
urlmon_free(This);
URLMON_UnlockModule();
}
......@@ -790,7 +790,7 @@ static const IInternetZoneManagerVtbl ZoneMgrImplVtbl = {
HRESULT ZoneMgrImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj)
{
ZoneMgrImpl* ret = HeapAlloc(GetProcessHeap(), 0, sizeof(ZoneMgrImpl));
ZoneMgrImpl* ret = urlmon_alloc(sizeof(ZoneMgrImpl));
TRACE("(%p %p)\n", pUnkOuter, ppobj);
ret->lpVtbl = &ZoneMgrImplVtbl;
......
......@@ -68,12 +68,12 @@ static HRESULT get_protocol_cf(LPCWSTR schema, DWORD schema_len, CLSID *pclsid,
{'P','R','O','T','O','C','O','L','S','\\','H','a','n','d','l','e','r','\\'};
static const WCHAR wszCLSID[] = {'C','L','S','I','D',0};
wszKey = HeapAlloc(GetProcessHeap(), 0, sizeof(wszProtocolsKey)+(schema_len+1)*sizeof(WCHAR));
wszKey = urlmon_alloc(sizeof(wszProtocolsKey)+(schema_len+1)*sizeof(WCHAR));
memcpy(wszKey, wszProtocolsKey, sizeof(wszProtocolsKey));
memcpy(wszKey + sizeof(wszProtocolsKey)/sizeof(WCHAR), schema, (schema_len+1)*sizeof(WCHAR));
res = RegOpenKeyW(HKEY_CLASSES_ROOT, wszKey, &hkey);
HeapFree(GetProcessHeap(), 0, wszKey);
urlmon_free(wszKey);
if(res != ERROR_SUCCESS) {
TRACE("Could not open protocol handler key\n");
return E_FAIL;
......@@ -207,10 +207,10 @@ static HRESULT WINAPI InternetSession_RegisterNameSpace(IInternetSession *iface,
if(!pCF || !pwzProtocol)
return E_INVALIDARG;
new_name_space = HeapAlloc(GetProcessHeap(), 0, sizeof(name_space));
new_name_space = urlmon_alloc(sizeof(name_space));
size = (strlenW(pwzProtocol)+1)*sizeof(WCHAR);
new_name_space->protocol = HeapAlloc(GetProcessHeap(), 0, size);
new_name_space->protocol = urlmon_alloc(size);
memcpy(new_name_space->protocol, pwzProtocol, size);
IClassFactory_AddRef(pCF);
......@@ -247,8 +247,8 @@ static HRESULT WINAPI InternetSession_UnregisterNameSpace(IInternetSession *ifac
name_space_list = iter->next;
IClassFactory_Release(iter->cf);
HeapFree(GetProcessHeap(), 0, iter->protocol);
HeapFree(GetProcessHeap(), 0, iter);
urlmon_free(iter->protocol);
urlmon_free(iter);
return S_OK;
}
......
......@@ -101,7 +101,7 @@ static ULONG WINAPI Binding_Release(IBinding* iface)
TRACE("(%p) ref=%d\n",This, ref);
if(!ref) {
HeapFree(GetProcessHeap(), 0, This->URLName);
urlmon_free(This->URLName);
if (This->hCacheFile)
CloseHandle(This->hCacheFile);
if (This->pstrCache)
......@@ -112,7 +112,7 @@ static ULONG WINAPI Binding_Release(IBinding* iface)
if (This->pbscb)
IBindStatusCallback_Release(This->pbscb);
HeapFree(GetProcessHeap(), 0, This);
urlmon_free(This);
URLMON_UnlockModule();
}
......@@ -356,8 +356,8 @@ static ULONG WINAPI URLMonikerImpl_Release(IMoniker* iface)
/* destroy the object if there's no more reference on it */
if (!refCount) {
HeapFree(GetProcessHeap(),0,This->URLName);
HeapFree(GetProcessHeap(),0,This);
urlmon_free(This->URLName);
urlmon_free(This);
URLMON_UnlockModule();
}
......@@ -420,8 +420,8 @@ static HRESULT WINAPI URLMonikerImpl_Load(IMoniker* iface,IStream* pStm)
res = IStream_Read(pStm, &size, sizeof(ULONG), &got);
if(SUCCEEDED(res)) {
if(got == sizeof(ULONG)) {
HeapFree(GetProcessHeap(), 0, This->URLName);
This->URLName=HeapAlloc(GetProcessHeap(),0,size);
urlmon_free(This->URLName);
This->URLName = urlmon_alloc(size);
if(!This->URLName)
res = E_OUTOFMEMORY;
else {
......@@ -517,13 +517,13 @@ static HRESULT URLMonikerImpl_BindToStorage_hack(LPCWSTR URLName,
return E_NOTIMPL;
}
bind = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(Binding));
bind = urlmon_alloc_zero(sizeof(Binding));
bind->lpVtbl = &BindingVtbl;
bind->ref = 1;
URLMON_LockModule();
len = lstrlenW(URLName)+1;
bind->URLName = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
bind->URLName = urlmon_alloc(len*sizeof(WCHAR));
memcpy(bind->URLName, URLName, len*sizeof(WCHAR));
hres = UMCreateStreamOnCacheFile(bind->URLName, 0, szFileName, &bind->hCacheFile, &bind->pstrCache);
......@@ -561,15 +561,15 @@ static HRESULT URLMonikerImpl_BindToStorage_hack(LPCWSTR URLName,
url.dwStructSize = sizeof(url);
url.dwSchemeLength = url.dwHostNameLength = url.dwUrlPathLength = url.dwUserNameLength = url.dwPasswordLength = 1;
InternetCrackUrlW(URLName, 0, ICU_ESCAPE, &url);
host = HeapAlloc(GetProcessHeap(), 0, (url.dwHostNameLength + 1) * sizeof(WCHAR));
host = urlmon_alloc((url.dwHostNameLength + 1) * sizeof(WCHAR));
memcpy(host, url.lpszHostName, url.dwHostNameLength * sizeof(WCHAR));
host[url.dwHostNameLength] = '\0';
path = HeapAlloc(GetProcessHeap(), 0, (url.dwUrlPathLength + 1) * sizeof(WCHAR));
path = urlmon_alloc((url.dwUrlPathLength + 1) * sizeof(WCHAR));
memcpy(path, url.lpszUrlPath, url.dwUrlPathLength * sizeof(WCHAR));
path[url.dwUrlPathLength] = '\0';
if (url.dwUserNameLength)
{
user = HeapAlloc(GetProcessHeap(), 0, ((url.dwUserNameLength + 1) * sizeof(WCHAR)));
user = urlmon_alloc(((url.dwUserNameLength + 1) * sizeof(WCHAR)));
memcpy(user, url.lpszUserName, url.dwUserNameLength * sizeof(WCHAR));
user[url.dwUserNameLength] = 0;
}
......@@ -579,7 +579,7 @@ static HRESULT URLMonikerImpl_BindToStorage_hack(LPCWSTR URLName,
}
if (url.dwPasswordLength)
{
pass = HeapAlloc(GetProcessHeap(), 0, ((url.dwPasswordLength + 1) * sizeof(WCHAR)));
pass = urlmon_alloc(((url.dwPasswordLength + 1) * sizeof(WCHAR)));
memcpy(pass, url.lpszPassword, url.dwPasswordLength * sizeof(WCHAR));
pass[url.dwPasswordLength] = 0;
}
......@@ -711,10 +711,10 @@ static HRESULT URLMonikerImpl_BindToStorage_hack(LPCWSTR URLName,
Binding_FinishedDownload(bind, hres);
Binding_CloseCacheDownload(bind);
HeapFree(GetProcessHeap(), 0, user);
HeapFree(GetProcessHeap(), 0, pass);
HeapFree(GetProcessHeap(), 0, path);
HeapFree(GetProcessHeap(), 0, host);
urlmon_free(user);
urlmon_free(pass);
urlmon_free(path);
urlmon_free(host);
}
}
}
......@@ -1042,7 +1042,7 @@ static HRESULT URLMonikerImpl_Construct(URLMonikerImpl* This, LPCOLESTR lpszLeft
This->lpvtbl = &VT_URLMonikerImpl;
This->ref = 0;
This->URLName = HeapAlloc(GetProcessHeap(), 0, INTERNET_MAX_URL_LENGTH*sizeof(WCHAR));
This->URLName = urlmon_alloc(INTERNET_MAX_URL_LENGTH*sizeof(WCHAR));
if(lpszLeftURLName)
hres = CoInternetCombineUrl(lpszLeftURLName, lpszURLName, URL_FILE_USE_PATHURL,
......@@ -1052,14 +1052,14 @@ static HRESULT URLMonikerImpl_Construct(URLMonikerImpl* This, LPCOLESTR lpszLeft
This->URLName, INTERNET_MAX_URL_LENGTH, &sizeStr, 0);
if(FAILED(hres)) {
HeapFree(GetProcessHeap(), 0, This->URLName);
urlmon_free(This->URLName);
return hres;
}
URLMON_LockModule();
if(sizeStr != INTERNET_MAX_URL_LENGTH)
This->URLName = HeapReAlloc(GetProcessHeap(), 0, This->URLName, (sizeStr+1)*sizeof(WCHAR));
This->URLName = urlmon_realloc(This->URLName, (sizeStr+1)*sizeof(WCHAR));
TRACE("URLName = %s\n", debugstr_w(This->URLName));
......@@ -1092,7 +1092,7 @@ HRESULT WINAPI CreateURLMonikerEx(IMoniker *pmkContext, LPCWSTR szURL, IMoniker
if (dwFlags & URL_MK_UNIFORM) FIXME("ignoring flag URL_MK_UNIFORM\n");
if(!(obj = HeapAlloc(GetProcessHeap(), 0, sizeof(*obj))))
if(!(obj = urlmon_alloc(sizeof(*obj))))
return E_OUTOFMEMORY;
if(pmkContext) {
......@@ -1111,7 +1111,7 @@ HRESULT WINAPI CreateURLMonikerEx(IMoniker *pmkContext, LPCWSTR szURL, IMoniker
if(SUCCEEDED(hres))
hres = URLMonikerImpl_QueryInterface((IMoniker*)obj, &IID_IMoniker, (void**)ppmk);
else
HeapFree(GetProcessHeap(), 0, obj);
urlmon_free(obj);
return hres;
}
......@@ -1437,12 +1437,12 @@ HRESULT WINAPI URLDownloadToCacheFileA(LPUNKNOWN lpUnkCaller, LPCSTR szURL, LPST
if(szURL) {
len = MultiByteToWideChar(CP_ACP, 0, szURL, -1, NULL, 0);
url = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
url = urlmon_alloc(len*sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, szURL, -1, url, -1);
}
if(szFileName)
file_name = HeapAlloc(GetProcessHeap(), 0, dwBufLength*sizeof(WCHAR));
file_name = urlmon_alloc(dwBufLength*sizeof(WCHAR));
hres = URLDownloadToCacheFileW(lpUnkCaller, url, file_name, dwBufLength*sizeof(WCHAR),
dwReserved, pBSC);
......@@ -1450,8 +1450,8 @@ HRESULT WINAPI URLDownloadToCacheFileA(LPUNKNOWN lpUnkCaller, LPCSTR szURL, LPST
if(SUCCEEDED(hres) && file_name)
WideCharToMultiByte(CP_ACP, 0, file_name, -1, szFileName, dwBufLength, NULL, NULL);
HeapFree(GetProcessHeap(), 0, url);
HeapFree(GetProcessHeap(), 0, file_name);
urlmon_free(url);
urlmon_free(file_name);
return hres;
}
......
......@@ -54,7 +54,7 @@ HRESULT UMCreateStreamOnCacheFile(LPCWSTR pszURL,
HRESULT hr;
size = (strlenW(pszURL)+1)*sizeof(WCHAR);
url = HeapAlloc(GetProcessHeap(), 0, size);
url = urlmon_alloc(size);
memcpy(url, pszURL, size);
for (c = url; *c && *c != '#' && *c != '?'; ++c)
......@@ -72,7 +72,7 @@ HRESULT UMCreateStreamOnCacheFile(LPCWSTR pszURL,
else
hr = 0;
HeapFree(GetProcessHeap(), 0, url);
urlmon_free(url);
if (hr)
return hr;
......@@ -99,17 +99,13 @@ HRESULT UMCreateStreamOnCacheFile(LPCWSTR pszURL,
}
}
ucstr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,sizeof(IUMCacheStream));
if(ucstr )
ucstr = urlmon_alloc_zero(sizeof(IUMCacheStream));
if(ucstr)
{
ucstr->pszURL = HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY,
sizeof(WCHAR) * (lstrlenW(pszURL) + 1));
ucstr->pszURL = urlmon_alloc_zero(sizeof(WCHAR) * (lstrlenW(pszURL) + 1));
if (ucstr->pszURL)
{
ucstr->pszFileName = HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY,
sizeof(WCHAR) * (lstrlenW(pszFileName) + 1));
ucstr->pszFileName = urlmon_alloc_zero(sizeof(WCHAR) * (lstrlenW(pszFileName) + 1));
if (ucstr->pszFileName)
{
ucstr->lpVtbl=&stvt;
......@@ -123,9 +119,9 @@ HRESULT UMCreateStreamOnCacheFile(LPCWSTR pszURL,
return S_OK;
}
HeapFree(GetProcessHeap(), 0, ucstr->pszURL);
urlmon_free(ucstr->pszURL);
}
HeapFree(GetProcessHeap(), 0, ucstr);
urlmon_free(ucstr);
}
CloseHandle(handle);
if (phfile)
......@@ -211,9 +207,9 @@ static ULONG WINAPI IStream_fnRelease(IStream *iface)
TRACE(" destroying UMCacheStream (%p)\n",This);
UMCloseCacheFileStream(This);
CloseHandle(This->handle);
HeapFree(GetProcessHeap(), 0, This->pszFileName);
HeapFree(GetProcessHeap(), 0, This->pszURL);
HeapFree(GetProcessHeap(),0,This);
urlmon_free(This->pszFileName);
urlmon_free(This->pszURL);
urlmon_free(This);
}
return refCount;
}
......@@ -563,7 +559,7 @@ HRESULT WINAPI URLOpenBlockingStreamA(LPUNKNOWN pCaller, LPCSTR szURL,
return E_INVALIDARG;
len = MultiByteToWideChar(CP_ACP, 0, szURL, -1, NULL, 0);
szURLW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
szURLW = urlmon_alloc(len * sizeof(WCHAR));
if (!szURLW)
{
*ppStream = NULL;
......@@ -573,7 +569,7 @@ HRESULT WINAPI URLOpenBlockingStreamA(LPUNKNOWN pCaller, LPCSTR szURL,
hr = URLOpenBlockingStreamW(pCaller, szURLW, ppStream, dwReserved, lpfnCB);
HeapFree(GetProcessHeap(), 0, szURLW);
urlmon_free(szURLW);
return hr;
}
......@@ -615,14 +611,14 @@ HRESULT WINAPI URLOpenStreamA(LPUNKNOWN pCaller, LPCSTR szURL, DWORD dwReserved,
return E_INVALIDARG;
len = MultiByteToWideChar(CP_ACP, 0, szURL, -1, NULL, 0);
szURLW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
szURLW = urlmon_alloc(len * sizeof(WCHAR));
if (!szURLW)
return E_OUTOFMEMORY;
MultiByteToWideChar(CP_ACP, 0, szURL, -1, szURLW, len);
hr = URLOpenStreamW(pCaller, szURLW, dwReserved, lpfnCB);
HeapFree(GetProcessHeap(), 0, szURLW);
urlmon_free(szURLW);
return hr;
}
......
......@@ -63,4 +63,24 @@ HRESULT start_binding(LPCWSTR url, IBindCtx *pbc, REFIID riid, void **ppv);
HRESULT create_binding_protocol(LPCWSTR url, IInternetProtocol **protocol);
static inline void *urlmon_alloc(size_t len)
{
return HeapAlloc(GetProcessHeap(), 0, len);
}
static inline void *urlmon_alloc_zero(size_t len)
{
return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
}
static inline void *urlmon_realloc(void *mem, size_t len)
{
return HeapReAlloc(GetProcessHeap(), 0, mem, len);
}
static inline BOOL urlmon_free(void *mem)
{
return HeapFree(GetProcessHeap(), 0, mem);
}
#endif /* __WINE_URLMON_MAIN_H */
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