Dmitry Timoshkov : hlink: Avoid double computation of the string
length.
Alexandre Julliard
julliard at wine.codeweavers.com
Thu Aug 3 15:58:25 CDT 2006
Module: wine
Branch: refs/heads/master
Commit: f740a2806215c43ea6a37b534a1163919409ba63
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=f740a2806215c43ea6a37b534a1163919409ba63
Author: Dmitry Timoshkov <dmitry at codeweavers.com>
Date: Thu Aug 3 23:39:00 2006 +0900
hlink: Avoid double computation of the string length.
---
dlls/hlink/link.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/dlls/hlink/link.c b/dlls/hlink/link.c
index cce6955..4d3b074 100644
--- a/dlls/hlink/link.c
+++ b/dlls/hlink/link.c
@@ -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-cvs
mailing list