Rob Shearman : oleaut32:
Rewrite MSFT_ReadName and MSFT_ReadString to need one less allocation
and to fix a memory leak .
Alexandre Julliard
julliard at wine.codeweavers.com
Mon Oct 23 10:03:10 CDT 2006
Module: wine
Branch: master
Commit: b5c78d0dffaf9212dfa1db35404501a127e57bf7
URL: http://source.winehq.org/git/wine.git/?a=commit;h=b5c78d0dffaf9212dfa1db35404501a127e57bf7
Author: Rob Shearman <rob at codeweavers.com>
Date: Mon Oct 23 11:39:43 2006 +0100
oleaut32: Rewrite MSFT_ReadName and MSFT_ReadString to need one less allocation and to fix a memory leak.
---
dlls/oleaut32/typelib.c | 19 ++++++-------------
1 files changed, 6 insertions(+), 13 deletions(-)
diff --git a/dlls/oleaut32/typelib.c b/dlls/oleaut32/typelib.c
index cdf2fe1..e09a5d5 100644
--- a/dlls/oleaut32/typelib.c
+++ b/dlls/oleaut32/typelib.c
@@ -1511,7 +1511,6 @@ static BSTR MSFT_ReadName( TLBContext *p
char * name;
MSFT_NameIntro niName;
int lengthInChars;
- WCHAR* pwstring = NULL;
BSTR bstrName = NULL;
if (offset < 0)
@@ -1532,15 +1531,12 @@ static BSTR MSFT_ReadName( TLBContext *p
/* no invalid characters in string */
if (lengthInChars)
{
- pwstring = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*lengthInChars);
+ bstrName = SysAllocStringByteLen(NULL, lengthInChars * sizeof(WCHAR));
/* don't check for invalid character since this has been done previously */
- MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, name, -1, pwstring, lengthInChars);
-
- bstrName = SysAllocStringLen(pwstring, lengthInChars);
- lengthInChars = SysStringLen(bstrName);
- HeapFree(GetProcessHeap(), 0, pwstring);
+ MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, name, -1, bstrName, lengthInChars);
}
+ TLB_Free(name);
TRACE_(typelib)("%s %d\n", debugstr_w(bstrName), lengthInChars);
return bstrName;
@@ -1566,15 +1562,12 @@ static BSTR MSFT_ReadString( TLBContext
/* no invalid characters in string */
if (lengthInChars)
{
- WCHAR* pwstring = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*lengthInChars);
+ bstr = SysAllocStringByteLen(NULL, lengthInChars * sizeof(WCHAR));
/* don't check for invalid character since this has been done previously */
- MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, string, -1, pwstring, lengthInChars);
-
- bstr = SysAllocStringLen(pwstring, lengthInChars);
- lengthInChars = SysStringLen(bstr);
- HeapFree(GetProcessHeap(), 0, pwstring);
+ MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, string, -1, bstr, lengthInChars);
}
+ TLB_Free(string);
TRACE_(typelib)("%s %d\n", debugstr_w(bstr), lengthInChars);
return bstr;
More information about the wine-cvs
mailing list