Commit 0dad77af authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

hlink: Use CRT allocation functions.

parent 28423d79
......@@ -88,11 +88,11 @@ static ULONG WINAPI IHlinkBC_fnRelease (IHlinkBrowseContext* iface)
{
list_remove(&link->entry);
IHlink_Release(link->link);
heap_free(link);
free(link);
}
heap_free(This->BrowseWindowInfo);
heap_free(This);
free(This->BrowseWindowInfo);
free(This);
}
return ref;
......@@ -174,8 +174,8 @@ static HRESULT WINAPI IHlinkBC_SetBrowseWindowInfo(IHlinkBrowseContext* iface,
if(!phlbwi)
return E_INVALIDARG;
heap_free(This->BrowseWindowInfo);
This->BrowseWindowInfo = heap_alloc(phlbwi->cbSize);
free(This->BrowseWindowInfo);
This->BrowseWindowInfo = malloc(phlbwi->cbSize);
memcpy(This->BrowseWindowInfo, phlbwi, phlbwi->cbSize);
return S_OK;
......@@ -209,7 +209,7 @@ static HRESULT WINAPI IHlinkBC_SetInitialHlink(IHlinkBrowseContext* iface,
if (!list_empty(&This->links))
return CO_E_ALREADYINITIALIZED;
link = heap_alloc(sizeof(struct link_entry));
link = malloc(sizeof(struct link_entry));
if (!link) return E_OUTOFMEMORY;
HlinkCreateFromMoniker(pimkTarget, pwzLocation, pwzFriendlyName, NULL,
......@@ -375,14 +375,13 @@ HRESULT HLinkBrowseContext_Constructor(IUnknown *pUnkOuter, REFIID riid, void **
if (pUnkOuter)
return CLASS_E_NOAGGREGATION;
hl = heap_alloc_zero(sizeof(HlinkBCImpl));
hl = calloc(1, sizeof(*hl));
if (!hl)
return E_OUTOFMEMORY;
hl->ref = 1;
hl->IHlinkBrowseContext_iface.lpVtbl = &hlvt;
list_init(&hl->links);
hl->current = NULL;
*ppv = hl;
return S_OK;
......
......@@ -89,10 +89,10 @@ static ULONG WINAPI ExtServUnk_Release(IUnknown *iface)
TRACE("(%p) ref=%ld\n", This, ref);
if(!ref) {
heap_free(This->username);
heap_free(This->password);
heap_free(This->headers);
heap_free(This);
free(This->username);
free(This->password);
free(This->headers);
free(This);
}
return ref;
......@@ -236,7 +236,7 @@ static HRESULT ExtServ_ImplSetAdditionalHeaders(ExtensionService* This, LPCWSTR
{
int len;
heap_free(This->headers);
free(This->headers);
This->headers = NULL;
if (!pwzAdditionalHeaders)
......@@ -245,11 +245,11 @@ static HRESULT ExtServ_ImplSetAdditionalHeaders(ExtensionService* This, LPCWSTR
len = lstrlenW(pwzAdditionalHeaders);
if(len && pwzAdditionalHeaders[len-1] != '\n' && pwzAdditionalHeaders[len-1] != '\r') {
This->headers = heap_alloc(len*sizeof(WCHAR) + sizeof(L"\r\n"));
This->headers = malloc(len*sizeof(WCHAR) + sizeof(L"\r\n"));
memcpy(This->headers, pwzAdditionalHeaders, len*sizeof(WCHAR));
memcpy(This->headers+len, L"\r\n", sizeof(L"\r\n"));
}else {
This->headers = hlink_strdupW(pwzAdditionalHeaders);
This->headers = wcsdup(pwzAdditionalHeaders);
}
return S_OK;
......@@ -266,12 +266,12 @@ static HRESULT WINAPI ExtServ_SetAdditionalHeaders(IExtensionServices* iface, LP
static HRESULT ExtServ_ImplSetAuthenticateData(ExtensionService* This, HWND phwnd, LPCWSTR pwzUsername, LPCWSTR pwzPassword)
{
heap_free(This->username);
heap_free(This->password);
free(This->username);
free(This->password);
This->hwnd = phwnd;
This->username = hlink_strdupW(pwzUsername);
This->password = hlink_strdupW(pwzPassword);
This->username = wcsdup(pwzUsername);
This->password = wcsdup(pwzPassword);
return S_OK;
}
......@@ -307,17 +307,14 @@ HRESULT WINAPI HlinkCreateExtensionServices(LPCWSTR pwzAdditionalHeaders,
phwnd, debugstr_w(pszUsername), debugstr_w(pszPassword),
punkOuter, debugstr_guid(riid), ppv);
ret = heap_alloc(sizeof(*ret));
if (!(ret = calloc(1, sizeof(*ret))))
return E_OUTOFMEMORY;
ret->IUnknown_inner.lpVtbl = &ExtServUnkVtbl;
ret->IAuthenticate_iface.lpVtbl = &AuthenticateVtbl;
ret->IHttpNegotiate_iface.lpVtbl = &HttpNegotiateVtbl;
ret->IExtensionServices_iface.lpVtbl = &ExtServVtbl;
ret->ref = 1;
ret->headers = NULL;
ret->hwnd = NULL;
ret->username = NULL;
ret->password = NULL;
ExtServ_ImplSetAuthenticateData(ret, phwnd, pszUsername, pszPassword);
ExtServ_ImplSetAdditionalHeaders(ret, pwzAdditionalHeaders);
......
......@@ -103,7 +103,7 @@ HRESULT WINAPI HlinkCreateFromString( LPCWSTR pwzTarget, LPCWSTR pwzLocation,
else
{
int tgt_len = hash - pwzTarget;
tgt = heap_alloc((tgt_len + 1) * sizeof(WCHAR));
tgt = malloc((tgt_len + 1) * sizeof(WCHAR));
if (!tgt)
return E_OUTOFMEMORY;
memcpy(tgt, pwzTarget, tgt_len * sizeof(WCHAR));
......@@ -116,7 +116,7 @@ HRESULT WINAPI HlinkCreateFromString( LPCWSTR pwzTarget, LPCWSTR pwzLocation,
}
else
{
tgt = hlink_strdupW(pwzTarget);
tgt = wcsdup(pwzTarget);
if (!tgt)
return E_OUTOFMEMORY;
loc = pwzLocation;
......@@ -130,7 +130,7 @@ HRESULT WINAPI HlinkCreateFromString( LPCWSTR pwzTarget, LPCWSTR pwzLocation,
IHlink_SetStringReference(hl, HLINKSETF_TARGET | HLINKSETF_LOCATION, tgt, loc);
heap_free(tgt);
free(tgt);
if (pwzFriendlyName)
IHlink_SetFriendlyName(hl, pwzFriendlyName);
......
......@@ -27,26 +27,9 @@
#include "ole2.h"
#include "hlink.h"
#include "wine/heap.h"
extern HRESULT HLink_Constructor(IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
extern HRESULT HLinkBrowseContext_Constructor(IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
static inline LPWSTR hlink_strdupW(LPCWSTR str)
{
LPWSTR ret = NULL;
if(str) {
DWORD size;
size = (lstrlenW(str)+1)*sizeof(WCHAR);
ret = heap_alloc(size);
memcpy(ret, str, size);
}
return ret;
}
static inline LPWSTR hlink_co_strdupW(LPCWSTR str)
{
LPWSTR ret = NULL;
......
......@@ -169,14 +169,14 @@ static ULONG WINAPI IHlink_fnRelease (IHlink* iface)
return refCount;
TRACE("-- destroying IHlink (%p)\n", This);
heap_free(This->FriendlyName);
heap_free(This->TargetFrameName);
heap_free(This->Location);
free(This->FriendlyName);
free(This->TargetFrameName);
free(This->Location);
if (This->Moniker)
IMoniker_Release(This->Moniker);
if (This->Site)
IHlinkSite_Release(This->Site);
heap_free(This);
free(This);
return 0;
}
......@@ -248,8 +248,8 @@ static HRESULT WINAPI IHlink_fnSetMonikerReference( IHlink* iface,
}
if(rfHLSETF & HLINKSETF_LOCATION){
heap_free(This->Location);
This->Location = hlink_strdupW( pwzLocation );
free(This->Location);
This->Location = wcsdup( pwzLocation );
}
return S_OK;
......@@ -310,10 +310,10 @@ static HRESULT WINAPI IHlink_fnSetStringReference(IHlink* iface,
if (grfHLSETF & HLINKSETF_LOCATION)
{
heap_free(This->Location);
free(This->Location);
This->Location = NULL;
if (pwzLocation && *pwzLocation)
This->Location = hlink_strdupW( pwzLocation );
This->Location = wcsdup( pwzLocation );
}
return S_OK;
......@@ -399,8 +399,8 @@ static HRESULT WINAPI IHlink_fnSetFriendlyName (IHlink *iface,
TRACE("(%p) -> (%s)\n", This, debugstr_w(pwzFriendlyName));
heap_free(This->FriendlyName);
This->FriendlyName = hlink_strdupW( pwzFriendlyName );
free(This->FriendlyName);
This->FriendlyName = wcsdup( pwzFriendlyName );
return S_OK;
}
......@@ -447,8 +447,8 @@ static HRESULT WINAPI IHlink_fnSetTargetFrameName(IHlink* iface,
HlinkImpl *This = impl_from_IHlink(iface);
TRACE("(%p)->(%s)\n", This, debugstr_w(pwzTargetFramename));
heap_free(This->TargetFrameName);
This->TargetFrameName = hlink_strdupW( pwzTargetFramename );
free(This->TargetFrameName);
This->TargetFrameName = wcsdup( pwzTargetFramename );
return S_OK;
}
......@@ -767,18 +767,18 @@ static HRESULT read_hlink_string(IStream *pStm, LPWSTR *out_str)
TRACE("read len %ld\n", len);
str = heap_alloc(len * sizeof(WCHAR));
str = malloc(len * sizeof(WCHAR));
if (!str) return E_OUTOFMEMORY;
hr = IStream_Read(pStm, str, len * sizeof(WCHAR), &read);
if (FAILED(hr))
{
heap_free(str);
free(str);
return hr;
}
if (read != len * sizeof(WCHAR))
{
heap_free(str);
free(str);
return STG_E_READFAULT;
}
TRACE("read string %s\n", debugstr_w(str));
......@@ -1137,8 +1137,7 @@ HRESULT HLink_Constructor(IUnknown *pUnkOuter, REFIID riid, void **ppv)
if (pUnkOuter)
return CLASS_E_NOAGGREGATION;
hl = heap_alloc_zero(sizeof(HlinkImpl));
if (!hl)
if (!(hl = calloc(1, sizeof(*hl))))
return E_OUTOFMEMORY;
hl->ref = 1;
......
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