hlink: Create a strdupW function and use it.
This commit is contained in:
parent
88cc410fd6
commit
dc3d475147
|
@ -68,6 +68,18 @@ static inline HlinkImpl* HlinkImpl_from_IDataObject( IDataObject* iface)
|
||||||
return (HlinkImpl*) ((CHAR*)iface - FIELD_OFFSET(HlinkImpl, lpDOVtbl));
|
return (HlinkImpl*) ((CHAR*)iface - FIELD_OFFSET(HlinkImpl, lpDOVtbl));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline LPWSTR strdupW( LPCWSTR str )
|
||||||
|
{
|
||||||
|
LPWSTR r;
|
||||||
|
|
||||||
|
if (!str)
|
||||||
|
return NULL;
|
||||||
|
r = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(str)+1) * sizeof (WCHAR));
|
||||||
|
if (r)
|
||||||
|
lstrcpyW(r, str);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
static inline void __GetMoniker(HlinkImpl* This, IMoniker** moniker)
|
static inline void __GetMoniker(HlinkImpl* This, IMoniker** moniker)
|
||||||
{
|
{
|
||||||
*moniker = NULL;
|
*moniker = NULL;
|
||||||
|
@ -216,13 +228,7 @@ static HRESULT WINAPI IHlink_fnSetMonikerReference( IHlink* iface,
|
||||||
IMoniker_AddRef(This->Moniker);
|
IMoniker_AddRef(This->Moniker);
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(), 0, This->Location);
|
HeapFree(GetProcessHeap(), 0, This->Location);
|
||||||
This->Location = NULL;
|
This->Location = strdupW( pwzLocation );
|
||||||
if (pwzLocation)
|
|
||||||
{
|
|
||||||
This->Location = HeapAlloc(GetProcessHeap(), 0,
|
|
||||||
(lstrlenW(pwzLocation)+1)*sizeof(WCHAR));
|
|
||||||
lstrcpyW(This->Location, pwzLocation);
|
|
||||||
}
|
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
@ -238,25 +244,12 @@ static HRESULT WINAPI IHlink_fnSetStringReference(IHlink* iface,
|
||||||
if (grfHLSETF & HLINKSETF_TARGET)
|
if (grfHLSETF & HLINKSETF_TARGET)
|
||||||
{
|
{
|
||||||
HeapFree(GetProcessHeap(), 0, This->Target);
|
HeapFree(GetProcessHeap(), 0, This->Target);
|
||||||
This->Target = NULL;
|
This->Target = strdupW( pwzTarget );
|
||||||
if (pwzTarget)
|
|
||||||
{
|
|
||||||
This->Target = HeapAlloc(GetProcessHeap(), 0,
|
|
||||||
(lstrlenW(pwzTarget)+1)*sizeof(WCHAR));
|
|
||||||
lstrcpyW(This->Target, pwzTarget);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (grfHLSETF & HLINKSETF_LOCATION)
|
if (grfHLSETF & HLINKSETF_LOCATION)
|
||||||
{
|
{
|
||||||
HeapFree(GetProcessHeap(), 0, This->Location);
|
HeapFree(GetProcessHeap(), 0, This->Location);
|
||||||
This->Location = NULL;
|
This->Location = strdupW( pwzLocation );
|
||||||
if (pwzLocation)
|
|
||||||
{
|
|
||||||
This->Location =
|
|
||||||
HeapAlloc(GetProcessHeap(), 0, (lstrlenW(pwzLocation)+1)
|
|
||||||
*sizeof(WCHAR));
|
|
||||||
lstrcpyW(This->Location, pwzLocation);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
@ -347,9 +340,7 @@ static HRESULT WINAPI IHlink_fnSetFriendlyName (IHlink *iface,
|
||||||
TRACE("(%p) -> (%s)\n", This, debugstr_w(pwzFriendlyName));
|
TRACE("(%p) -> (%s)\n", This, debugstr_w(pwzFriendlyName));
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(), 0, This->FriendlyName);
|
HeapFree(GetProcessHeap(), 0, This->FriendlyName);
|
||||||
This->FriendlyName = HeapAlloc(GetProcessHeap(), 0,
|
This->FriendlyName = strdupW( pwzFriendlyName );
|
||||||
(lstrlenW(pwzFriendlyName)+1) * sizeof(WCHAR));
|
|
||||||
lstrcpyW(This->FriendlyName, pwzFriendlyName);
|
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
@ -396,9 +387,7 @@ static HRESULT WINAPI IHlink_fnSetTargetFrameName(IHlink* iface,
|
||||||
TRACE("(%p)->(%s)\n", This, debugstr_w(pwzTargetFramename));
|
TRACE("(%p)->(%s)\n", This, debugstr_w(pwzTargetFramename));
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(), 0, This->TargetFrameName);
|
HeapFree(GetProcessHeap(), 0, This->TargetFrameName);
|
||||||
This->TargetFrameName = HeapAlloc(GetProcessHeap(), 0,
|
This->TargetFrameName = strdupW( pwzTargetFramename );
|
||||||
(lstrlenW(pwzTargetFramename)+1) * sizeof(WCHAR));
|
|
||||||
lstrcpyW(This->TargetFrameName, pwzTargetFramename);
|
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue