Avoid double computation of the string length
Dmitry Timoshkov
dmitry at codeweavers.com
Thu Aug 3 09:39:00 CDT 2006
Hello,
Changelog:
Avoid double computation of the string length.
--- cvs/hq/wine/dlls/hlink/link.c 2006-08-03 19:50:47.000000000 +0900
+++ wine/dlls/hlink/link.c 2006-08-03 19:55:03.000000000 +0900
@@ -72,24 +72,28 @@ static inline HlinkImpl* HlinkImpl_from_
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;
}
More information about the wine-patches
mailing list