hlink: Avoid double computation of the string length.

This commit is contained in:
Dmitry Timoshkov 2006-08-03 23:39:00 +09:00 committed by Alexandre Julliard
parent 145e06040d
commit f740a28062
1 changed files with 8 additions and 4 deletions

View File

@ -72,24 +72,28 @@ static inline HlinkImpl* HlinkImpl_from_IDataObject( IDataObject* iface)
static inline LPWSTR strdupW( LPCWSTR str )
{
LPWSTR r;
UINT len;
if (!str)
return NULL;
r = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(str)+1) * sizeof (WCHAR));
len = (lstrlenW(str)+1) * sizeof (WCHAR);
r = HeapAlloc(GetProcessHeap(), 0, len);
if (r)
lstrcpyW(r, str);
memcpy(r, str, len);
return r;
}
static inline LPWSTR co_strdupW( LPCWSTR str )
{
LPWSTR r;
UINT len;
if (!str)
return NULL;
r = CoTaskMemAlloc((lstrlenW(str)+1) * sizeof (WCHAR));
len = (lstrlenW(str)+1) * sizeof (WCHAR);
r = CoTaskMemAlloc(len);
if (r)
lstrcpyW(r, str);
memcpy(r, str, len);
return r;
}