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