Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/hlink/browse_ctx.c | 15 +++++++-------- dlls/hlink/extserv.c | 29 +++++++++++++---------------- dlls/hlink/hlink_main.c | 6 +++--- dlls/hlink/hlink_private.h | 17 ----------------- dlls/hlink/link.c | 33 ++++++++++++++++----------------- 5 files changed, 39 insertions(+), 61 deletions(-)
diff --git a/dlls/hlink/browse_ctx.c b/dlls/hlink/browse_ctx.c index 58a43b180fc..44db1a1fc0c 100644 --- a/dlls/hlink/browse_ctx.c +++ b/dlls/hlink/browse_ctx.c @@ -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; diff --git a/dlls/hlink/extserv.c b/dlls/hlink/extserv.c index 7a5f62246f4..d6587ce9e79 100644 --- a/dlls/hlink/extserv.c +++ b/dlls/hlink/extserv.c @@ -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); diff --git a/dlls/hlink/hlink_main.c b/dlls/hlink/hlink_main.c index 46a401824ae..e70a066bb05 100644 --- a/dlls/hlink/hlink_main.c +++ b/dlls/hlink/hlink_main.c @@ -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); diff --git a/dlls/hlink/hlink_private.h b/dlls/hlink/hlink_private.h index 565c264fee9..cf1befdb78f 100644 --- a/dlls/hlink/hlink_private.h +++ b/dlls/hlink/hlink_private.h @@ -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; diff --git a/dlls/hlink/link.c b/dlls/hlink/link.c index 46597488ab1..305f7136a44 100644 --- a/dlls/hlink/link.c +++ b/dlls/hlink/link.c @@ -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;
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/hlink/browse_ctx.c | 22 ++++++++++++++-------- dlls/hlink/tests/browse_ctx.c | 10 ++++++++++ 2 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/dlls/hlink/browse_ctx.c b/dlls/hlink/browse_ctx.c index 44db1a1fc0c..88ee3ea29af 100644 --- a/dlls/hlink/browse_ctx.c +++ b/dlls/hlink/browse_ctx.c @@ -53,14 +53,17 @@ static HRESULT WINAPI IHlinkBC_fnQueryInterface( IHlinkBrowseContext *iface,
if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IHlinkBrowseContext)) - *ppvObj = This; - - if (*ppvObj) { - IUnknown_AddRef((IUnknown*)(*ppvObj)); - return S_OK; + *ppvObj = &This->IHlinkBrowseContext_iface; } - return E_NOINTERFACE; + else + { + *ppvObj = NULL; + return E_NOINTERFACE; + } + + IUnknown_AddRef((IUnknown *)*ppvObj); + return S_OK; }
static ULONG WINAPI IHlinkBC_fnAddRef (IHlinkBrowseContext* iface) @@ -368,6 +371,7 @@ static const IHlinkBrowseContextVtbl hlvt = HRESULT HLinkBrowseContext_Constructor(IUnknown *pUnkOuter, REFIID riid, void **ppv) { HlinkBCImpl * hl; + HRESULT hr;
TRACE("unkOut=%p riid=%s\n", pUnkOuter, debugstr_guid(riid)); *ppv = NULL; @@ -383,6 +387,8 @@ HRESULT HLinkBrowseContext_Constructor(IUnknown *pUnkOuter, REFIID riid, void ** hl->IHlinkBrowseContext_iface.lpVtbl = &hlvt; list_init(&hl->links);
- *ppv = hl; - return S_OK; + hr = IHlinkBrowseContext_QueryInterface(&hl->IHlinkBrowseContext_iface, riid, ppv); + IHlinkBrowseContext_Release(&hl->IHlinkBrowseContext_iface); + + return hr; } diff --git a/dlls/hlink/tests/browse_ctx.c b/dlls/hlink/tests/browse_ctx.c index c0a731bb334..4bd7af9d42f 100644 --- a/dlls/hlink/tests/browse_ctx.c +++ b/dlls/hlink/tests/browse_ctx.c @@ -197,10 +197,20 @@ static void test_GetObject(void) IMoniker_Release(dummy); }
+static void test_interfaces(void) +{ + IHlinkBrowseContext *bc; + HRESULT hr; + + hr = HlinkCreateBrowseContext(NULL, &IID_IMoniker, (void **)&bc); + ok(hr == E_NOINTERFACE, "Unexpected hr %#lx.\n", hr); +} + START_TEST(browse_ctx) { CoInitialize(NULL);
+ test_interfaces(); test_SetInitialHlink(); test_BrowseWindowInfo(); test_GetObject();
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/hlink/link.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/dlls/hlink/link.c b/dlls/hlink/link.c index 305f7136a44..8c7b06f6f2a 100644 --- a/dlls/hlink/link.c +++ b/dlls/hlink/link.c @@ -1130,6 +1130,7 @@ static const IBindStatusCallbackVtbl bind_callback_vtbl = HRESULT HLink_Constructor(IUnknown *pUnkOuter, REFIID riid, void **ppv) { HlinkImpl * hl; + HRESULT hr;
TRACE("unkOut=%p riid=%s\n", pUnkOuter, debugstr_guid(riid)); *ppv = NULL; @@ -1146,6 +1147,8 @@ HRESULT HLink_Constructor(IUnknown *pUnkOuter, REFIID riid, void **ppv) hl->IDataObject_iface.lpVtbl = &dovt; hl->IBindStatusCallback_iface.lpVtbl = &bind_callback_vtbl;
- *ppv = hl; - return S_OK; + hr = IHlink_QueryInterface(&hl->IHlink_iface, riid, ppv); + IHlink_Release(&hl->IHlink_iface); + + return hr; }
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/hlink/hlink_main.c | 15 +++++++-------- dlls/hlink/tests/hlink.c | 17 +++++++++++++++++ 2 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/dlls/hlink/hlink_main.c b/dlls/hlink/hlink_main.c index e70a066bb05..3f7a3fcd62e 100644 --- a/dlls/hlink/hlink_main.c +++ b/dlls/hlink/hlink_main.c @@ -49,15 +49,15 @@ HRESULT WINAPI HlinkCreateFromMoniker( IMoniker *pimkTrgt, LPCWSTR pwzLocation, IUnknown* piunkOuter, REFIID riid, void** ppvObj) { IHlink *hl = NULL; - HRESULT r; + HRESULT hr;
TRACE("%p %s %s %p %li %p %s %p\n", pimkTrgt, debugstr_w(pwzLocation), debugstr_w(pwzFriendlyName), pihlsite, dwSiteData, piunkOuter, debugstr_guid(riid), ppvObj);
- r = CoCreateInstance(&CLSID_StdHlink, piunkOuter, CLSCTX_INPROC_SERVER, riid, (LPVOID*)&hl); - if (FAILED(r)) - return r; + hr = CoCreateInstance(&CLSID_StdHlink, piunkOuter, CLSCTX_INPROC_SERVER, &IID_IHlink, (LPVOID*)&hl); + if (FAILED(hr)) + return hr;
IHlink_SetMonikerReference(hl, HLINKSETF_LOCATION | HLINKSETF_TARGET, pimkTrgt, pwzLocation);
@@ -66,11 +66,10 @@ HRESULT WINAPI HlinkCreateFromMoniker( IMoniker *pimkTrgt, LPCWSTR pwzLocation, if (pihlsite) IHlink_SetHlinkSite(hl, pihlsite, dwSiteData);
- *ppvObj = hl; - - TRACE("Returning %lx\n",r); + hr = IHlink_QueryInterface(hl, riid, ppvObj); + IHlink_Release(hl);
- return r; + return hr; }
/*********************************************************************** diff --git a/dlls/hlink/tests/hlink.c b/dlls/hlink/tests/hlink.c index 984f952c158..c5c8cd9c81b 100644 --- a/dlls/hlink/tests/hlink.c +++ b/dlls/hlink/tests/hlink.c @@ -2607,6 +2607,22 @@ static void test_HlinkUpdateStackItem(void) CHECK_CALLED(HLF_UpdateHlink); }
+static void test_HlinkCreateFromMoniker(void) +{ + IPersistStream *stream; + IMoniker *moniker; + HRESULT hr; + + hr = CreateItemMoniker(L"1", L"1", &moniker); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = HlinkCreateFromMoniker(moniker, L"1", L"a", NULL, 0, NULL, &IID_IPersistStream, (void **)&stream); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + IPersistStream_Release(stream); + + IMoniker_Release(moniker); +} + START_TEST(hlink) { CoInitialize(NULL); @@ -2627,6 +2643,7 @@ START_TEST(hlink) test_StdHlink(); test_Hlink_Navigate(); test_HlinkUpdateStackItem(); + test_HlinkCreateFromMoniker();
CoUninitialize(); }
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/hlink/hlink_main.c | 14 +++++++------- dlls/hlink/tests/hlink.c | 11 +++++++++++ 2 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/dlls/hlink/hlink_main.c b/dlls/hlink/hlink_main.c index 3f7a3fcd62e..8e269f5f375 100644 --- a/dlls/hlink/hlink_main.c +++ b/dlls/hlink/hlink_main.c @@ -80,7 +80,7 @@ HRESULT WINAPI HlinkCreateFromString( LPCWSTR pwzTarget, LPCWSTR pwzLocation, IUnknown* piunkOuter, REFIID riid, void** ppvObj) { IHlink *hl = NULL; - HRESULT r; + HRESULT hr; WCHAR *hash, *tgt; const WCHAR *loc;
@@ -88,9 +88,9 @@ HRESULT WINAPI HlinkCreateFromString( LPCWSTR pwzTarget, LPCWSTR pwzLocation, debugstr_w(pwzLocation), debugstr_w(pwzFriendlyName), pihlsite, dwSiteData, piunkOuter, debugstr_guid(riid), ppvObj);
- r = CoCreateInstance(&CLSID_StdHlink, piunkOuter, CLSCTX_INPROC_SERVER, riid, (LPVOID*)&hl); - if (FAILED(r)) - return r; + hr = CoCreateInstance(&CLSID_StdHlink, piunkOuter, CLSCTX_INPROC_SERVER, &IID_IHlink, (void **)&hl); + if (FAILED(hr)) + return hr;
if (pwzTarget) { @@ -137,10 +137,10 @@ HRESULT WINAPI HlinkCreateFromString( LPCWSTR pwzTarget, LPCWSTR pwzLocation, if (pihlsite) IHlink_SetHlinkSite(hl, pihlsite, dwSiteData);
- TRACE("Returning %lx\n",r); - *ppvObj = hl; + hr = IHlink_QueryInterface(hl, riid, ppvObj); + IHlink_Release(hl);
- return r; + return hr; }
diff --git a/dlls/hlink/tests/hlink.c b/dlls/hlink/tests/hlink.c index c5c8cd9c81b..3c2e8ebf455 100644 --- a/dlls/hlink/tests/hlink.c +++ b/dlls/hlink/tests/hlink.c @@ -2623,6 +2623,16 @@ static void test_HlinkCreateFromMoniker(void) IMoniker_Release(moniker); }
+static void test_HlinkCreateFromString(void) +{ + IPersistStream *stream; + HRESULT hr; + + hr = HlinkCreateFromString(L"http://winehq.org", NULL, NULL, NULL, 0, NULL, &IID_IPersistStream, (void **)&stream); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + IPersistStream_Release(stream); +} + START_TEST(hlink) { CoInitialize(NULL); @@ -2644,6 +2654,7 @@ START_TEST(hlink) test_Hlink_Navigate(); test_HlinkUpdateStackItem(); test_HlinkCreateFromMoniker(); + test_HlinkCreateFromString();
CoUninitialize(); }