msxml3: Optimize bstr_from_xmlChar implementation.

This commit is contained in:
Jacek Caban 2009-08-14 12:23:05 +02:00 committed by Alexandre Julliard
parent 489c1a8d43
commit 7447145d64
2 changed files with 14 additions and 20 deletions

View File

@ -59,7 +59,6 @@ xmlNodePtr xmlNodePtr_from_domnode( IXMLDOMNode *iface, xmlElementType type );
/* helpers */
extern xmlChar *xmlChar_from_wchar( LPWSTR str );
extern BSTR bstr_from_xmlChar( const xmlChar *buf );
extern LONG xmldoc_add_ref( xmlDocPtr doc );
extern LONG xmldoc_release( xmlDocPtr doc );
@ -87,6 +86,20 @@ static inline xmlnode *impl_from_IXMLDOMNode( IXMLDOMNode *iface )
extern HRESULT DOMDocument_create_from_xmldoc(xmlDocPtr xmldoc, IXMLDOMDocument2 **document);
static inline BSTR bstr_from_xmlChar(const xmlChar *str)
{
BSTR ret = NULL;
if(str) {
DWORD len = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)str, -1, NULL, 0);
ret = SysAllocStringLen(NULL, len-1);
if(ret)
MultiByteToWideChar( CP_UTF8, 0, (LPCSTR)str, -1, ret, len);
}
return ret;
}
#endif
void* libxslt_handle;

View File

@ -247,25 +247,6 @@ static HRESULT WINAPI xmlnode_get_nodeName(
return S_OK;
}
BSTR bstr_from_xmlChar( const xmlChar *buf )
{
DWORD len;
LPWSTR str;
BSTR bstr;
if ( !buf )
return NULL;
len = MultiByteToWideChar( CP_UTF8, 0, (LPCSTR) buf, -1, NULL, 0 );
str = HeapAlloc( GetProcessHeap(), 0, len * sizeof (WCHAR) );
if ( !str )
return NULL;
MultiByteToWideChar( CP_UTF8, 0, (LPCSTR) buf, -1, str, len );
bstr = SysAllocString( str );
HeapFree( GetProcessHeap(), 0, str );
return bstr;
}
static HRESULT WINAPI xmlnode_get_nodeValue(
IXMLDOMNode *iface,
VARIANT* value)