diff --git a/dlls/msxml3/attribute.c b/dlls/msxml3/attribute.c index 92cafad5367..9fabc469a7d 100644 --- a/dlls/msxml3/attribute.c +++ b/dlls/msxml3/attribute.c @@ -547,7 +547,7 @@ static const struct IXMLDOMAttributeVtbl domattr_vtbl = IUnknown* create_attribute( xmlNodePtr attribute ) { domattr *This; - HRESULT hr; + xmlnode *node; This = HeapAlloc( GetProcessHeap(), 0, sizeof *This ); if ( !This ) @@ -556,22 +556,15 @@ IUnknown* create_attribute( xmlNodePtr attribute ) This->lpVtbl = &domattr_vtbl; This->ref = 1; - This->node_unk = create_basic_node( attribute, (IUnknown*)&This->lpVtbl ); - if(!This->node_unk) + node = create_basic_node( attribute, (IUnknown*)&This->lpVtbl ); + if(!node) { HeapFree(GetProcessHeap(), 0, This); return NULL; } - hr = IUnknown_QueryInterface(This->node_unk, &IID_IXMLDOMNode, (LPVOID*)&This->node); - if(FAILED(hr)) - { - IUnknown_Release(This->node_unk); - HeapFree( GetProcessHeap(), 0, This ); - return NULL; - } - /* The ref on This->node is actually looped back into this object, so release it */ - IXMLDOMNode_Release(This->node); + This->node_unk = (IUnknown*)&node->lpInternalUnkVtbl; + This->node = IXMLDOMNode_from_impl(node); return (IUnknown*) &This->lpVtbl; } diff --git a/dlls/msxml3/cdata.c b/dlls/msxml3/cdata.c index 3d3c87514b9..a9b7fee34a0 100644 --- a/dlls/msxml3/cdata.c +++ b/dlls/msxml3/cdata.c @@ -770,7 +770,7 @@ static const struct IXMLDOMCDATASectionVtbl domcdata_vtbl = IUnknown* create_cdata( xmlNodePtr text ) { domcdata *This; - HRESULT hr; + xmlnode *node; This = HeapAlloc( GetProcessHeap(), 0, sizeof *This ); if ( !This ) @@ -779,22 +779,15 @@ IUnknown* create_cdata( xmlNodePtr text ) This->lpVtbl = &domcdata_vtbl; This->ref = 1; - This->node_unk = create_basic_node( text, (IUnknown*)&This->lpVtbl ); - if(!This->node_unk) + node = create_basic_node( text, (IUnknown*)&This->lpVtbl ); + if(!node) { HeapFree(GetProcessHeap(), 0, This); return NULL; } - hr = IUnknown_QueryInterface(This->node_unk, &IID_IXMLDOMNode, (LPVOID*)&This->node); - if(FAILED(hr)) - { - IUnknown_Release(This->node_unk); - HeapFree( GetProcessHeap(), 0, This ); - return NULL; - } - /* The ref on This->node is actually looped back into this object, so release it */ - IXMLDOMNode_Release(This->node); + This->node_unk = (IUnknown*)&node->lpInternalUnkVtbl; + This->node = IXMLDOMNode_from_impl(node); return (IUnknown*) &This->lpVtbl; } diff --git a/dlls/msxml3/comment.c b/dlls/msxml3/comment.c index 717c73d0c45..a8cf528a374 100644 --- a/dlls/msxml3/comment.c +++ b/dlls/msxml3/comment.c @@ -768,7 +768,7 @@ static const struct IXMLDOMCommentVtbl domcomment_vtbl = IUnknown* create_comment( xmlNodePtr comment ) { domcomment *This; - HRESULT hr; + xmlnode *node; This = HeapAlloc( GetProcessHeap(), 0, sizeof *This ); if ( !This ) @@ -777,22 +777,15 @@ IUnknown* create_comment( xmlNodePtr comment ) This->lpVtbl = &domcomment_vtbl; This->ref = 1; - This->node_unk = create_basic_node( comment, (IUnknown*)&This->lpVtbl ); - if(!This->node_unk) + node = create_basic_node( comment, (IUnknown*)&This->lpVtbl ); + if(!node) { HeapFree(GetProcessHeap(), 0, This); return NULL; } - hr = IUnknown_QueryInterface(This->node_unk, &IID_IXMLDOMNode, (LPVOID*)&This->node); - if(FAILED(hr)) - { - IUnknown_Release(This->node_unk); - HeapFree( GetProcessHeap(), 0, This ); - return NULL; - } - /* The ref on This->node is actually looped back into this object, so release it */ - IXMLDOMNode_Release(This->node); + This->node_unk = (IUnknown*)&node->lpInternalUnkVtbl; + This->node = IXMLDOMNode_from_impl(node); return (IUnknown*) &This->lpVtbl; } diff --git a/dlls/msxml3/docfrag.c b/dlls/msxml3/docfrag.c index f922faaa229..572d223d44d 100644 --- a/dlls/msxml3/docfrag.c +++ b/dlls/msxml3/docfrag.c @@ -520,7 +520,7 @@ static const struct IXMLDOMDocumentFragmentVtbl domfrag_vtbl = IUnknown* create_doc_fragment( xmlNodePtr fragment ) { domfrag *This; - HRESULT hr; + xmlnode *node; This = HeapAlloc( GetProcessHeap(), 0, sizeof *This ); if ( !This ) @@ -529,22 +529,15 @@ IUnknown* create_doc_fragment( xmlNodePtr fragment ) This->lpVtbl = &domfrag_vtbl; This->ref = 1; - This->node_unk = create_basic_node( fragment, (IUnknown*)&This->lpVtbl ); - if(!This->node_unk) + node = create_basic_node( fragment, (IUnknown*)&This->lpVtbl ); + if(!node) { HeapFree(GetProcessHeap(), 0, This); return NULL; } - hr = IUnknown_QueryInterface(This->node_unk, &IID_IXMLDOMNode, (LPVOID*)&This->node); - if(FAILED(hr)) - { - IUnknown_Release(This->node_unk); - HeapFree( GetProcessHeap(), 0, This ); - return NULL; - } - /* The ref on This->node is actually looped back into this object, so release it */ - IXMLDOMNode_Release(This->node); + This->node_unk = (IUnknown*)&node->lpInternalUnkVtbl; + This->node = IXMLDOMNode_from_impl(node); return (IUnknown*) &This->lpVtbl; } diff --git a/dlls/msxml3/domdoc.c b/dlls/msxml3/domdoc.c index 1724093a39e..2da24706557 100644 --- a/dlls/msxml3/domdoc.c +++ b/dlls/msxml3/domdoc.c @@ -2198,7 +2198,7 @@ static dispex_static_data_t domdoc_dispex = { HRESULT DOMDocument_create_from_xmldoc(xmlDocPtr xmldoc, IXMLDOMDocument2 **document) { domdoc *doc; - HRESULT hr; + xmlnode *node; doc = HeapAlloc( GetProcessHeap(), 0, sizeof (*doc) ); if( !doc ) @@ -2222,26 +2222,18 @@ HRESULT DOMDocument_create_from_xmldoc(xmlDocPtr xmldoc, IXMLDOMDocument2 **docu doc->safeopt = 0; doc->bsc = NULL; - doc->node_unk = create_basic_node( (xmlNodePtr)xmldoc, (IUnknown*)&doc->lpVtbl ); - if(!doc->node_unk) + node = create_basic_node( (xmlNodePtr)xmldoc, (IUnknown*)&doc->lpVtbl ); + if(!node) { HeapFree(GetProcessHeap(), 0, doc); return E_FAIL; } - hr = IUnknown_QueryInterface(doc->node_unk, &IID_IXMLDOMNode, (LPVOID*)&doc->node); - if(FAILED(hr)) - { - IUnknown_Release(doc->node_unk); - HeapFree( GetProcessHeap(), 0, doc ); - return E_FAIL; - } + doc->node_unk = (IUnknown*)&node->lpInternalUnkVtbl; + doc->node = IXMLDOMNode_from_impl(node); init_dispex(&doc->dispex, (IUnknown*)&doc->lpVtbl, &domdoc_dispex); - /* The ref on doc->node is actually looped back into this object, so release it */ - IXMLDOMNode_Release(doc->node); - *document = (IXMLDOMDocument2*)&doc->lpVtbl; TRACE("returning iface %p\n", *document); diff --git a/dlls/msxml3/element.c b/dlls/msxml3/element.c index 4f0bce93acc..8b72181e896 100644 --- a/dlls/msxml3/element.c +++ b/dlls/msxml3/element.c @@ -790,7 +790,7 @@ static const struct IUnknownVtbl internal_unk_vtbl = IUnknown* create_element( xmlNodePtr element, IUnknown *pUnkOuter ) { domelem *This; - HRESULT hr; + xmlnode *node; This = HeapAlloc( GetProcessHeap(), 0, sizeof *This ); if ( !This ) @@ -805,22 +805,15 @@ IUnknown* create_element( xmlNodePtr element, IUnknown *pUnkOuter ) else This->pUnkOuter = (IUnknown *)&This->lpInternalUnkVtbl; - This->node_unk = create_basic_node( element, (IUnknown*)&This->lpVtbl ); - if(!This->node_unk) + node = create_basic_node( element, (IUnknown*)&This->lpVtbl ); + if(!node) { HeapFree(GetProcessHeap(), 0, This); return NULL; } - hr = IUnknown_QueryInterface(This->node_unk, &IID_IXMLDOMNode, (LPVOID*)&This->node); - if(FAILED(hr)) - { - IUnknown_Release(This->node_unk); - HeapFree( GetProcessHeap(), 0, This ); - return NULL; - } - /* The ref on This->node is actually looped back into this object, so release it */ - IXMLDOMNode_Release(This->node); + This->node_unk = (IUnknown*)&node->lpInternalUnkVtbl; + This->node = IXMLDOMNode_from_impl(node); return (IUnknown*) &This->lpInternalUnkVtbl; } diff --git a/dlls/msxml3/entityref.c b/dlls/msxml3/entityref.c index a72b11022e7..1726e2f1697 100644 --- a/dlls/msxml3/entityref.c +++ b/dlls/msxml3/entityref.c @@ -519,7 +519,7 @@ static const struct IXMLDOMEntityReferenceVtbl entityref_vtbl = IUnknown* create_doc_entity_ref( xmlNodePtr entity ) { entityref *This; - HRESULT hr; + xmlnode *node; This = HeapAlloc( GetProcessHeap(), 0, sizeof *This ); if ( !This ) @@ -528,22 +528,15 @@ IUnknown* create_doc_entity_ref( xmlNodePtr entity ) This->lpVtbl = &entityref_vtbl; This->ref = 1; - This->node_unk = create_basic_node( entity, (IUnknown*)&This->lpVtbl ); - if(!This->node_unk) + node = create_basic_node( entity, (IUnknown*)&This->lpVtbl ); + if(!node) { HeapFree(GetProcessHeap(), 0, This); return NULL; } - hr = IUnknown_QueryInterface(This->node_unk, &IID_IXMLDOMNode, (LPVOID*)&This->node); - if(FAILED(hr)) - { - IUnknown_Release(This->node_unk); - HeapFree( GetProcessHeap(), 0, This ); - return NULL; - } - /* The ref on This->node is actually looped back into this object, so release it */ - IXMLDOMNode_Release(This->node); + This->node_unk = (IUnknown*)&node->lpInternalUnkVtbl; + This->node = IXMLDOMNode_from_impl(node); return (IUnknown*) &This->lpVtbl; } diff --git a/dlls/msxml3/msxml_private.h b/dlls/msxml3/msxml_private.h index 357810d8c9a..d09b3801fd5 100644 --- a/dlls/msxml3/msxml_private.h +++ b/dlls/msxml3/msxml_private.h @@ -39,7 +39,6 @@ extern IUnknown *create_domdoc( xmlNodePtr document ); extern IUnknown *create_xmldoc( void ); extern IXMLDOMNode *create_node( xmlNodePtr node ); -extern IUnknown *create_basic_node( xmlNodePtr node, IUnknown *pUnkOuter ); extern IUnknown *create_element( xmlNodePtr element, IUnknown *pUnkOuter ); extern IUnknown *create_attribute( xmlNodePtr attribute ); extern IUnknown *create_text( xmlNodePtr text ); @@ -84,6 +83,13 @@ static inline xmlnode *impl_from_IXMLDOMNode( IXMLDOMNode *iface ) return (xmlnode *)((char*)iface - FIELD_OFFSET(xmlnode, lpVtbl)); } +static inline IXMLDOMNode *IXMLDOMNode_from_impl(xmlnode *This) +{ + return (IXMLDOMNode*)&This->lpVtbl; +} + +extern xmlnode *create_basic_node(xmlNodePtr,IUnknown*); + extern HRESULT DOMDocument_create_from_xmldoc(xmlDocPtr xmldoc, IXMLDOMDocument2 **document); static inline BSTR bstr_from_xmlChar(const xmlChar *str) diff --git a/dlls/msxml3/node.c b/dlls/msxml3/node.c index 1841e6ed233..2876ef3a05e 100644 --- a/dlls/msxml3/node.c +++ b/dlls/msxml3/node.c @@ -1542,7 +1542,7 @@ static const struct IUnknownVtbl internal_unk_vtbl = Internal_Release }; -IUnknown *create_basic_node( xmlNodePtr node, IUnknown *pUnkOuter ) +xmlnode *create_basic_node( xmlNodePtr node, IUnknown *pUnkOuter ) { xmlnode *This; @@ -1564,7 +1564,7 @@ IUnknown *create_basic_node( xmlNodePtr node, IUnknown *pUnkOuter ) This->ref = 1; This->node = node; - return (IUnknown*)&This->lpInternalUnkVtbl; + return This; } IXMLDOMNode *create_node( xmlNodePtr node ) @@ -1599,7 +1599,7 @@ IXMLDOMNode *create_node( xmlNodePtr node ) break; default: FIXME("only creating basic node for type %d\n", node->type); - pUnk = create_basic_node( node, NULL ); + pUnk = (IUnknown*)&create_basic_node( node, NULL )->lpInternalUnkVtbl; } hr = IUnknown_QueryInterface(pUnk, &IID_IXMLDOMNode, (LPVOID*)&ret); diff --git a/dlls/msxml3/pi.c b/dlls/msxml3/pi.c index a38f355ce04..00a52665088 100644 --- a/dlls/msxml3/pi.c +++ b/dlls/msxml3/pi.c @@ -605,7 +605,7 @@ static const struct IXMLDOMProcessingInstructionVtbl dom_pi_vtbl = IUnknown* create_pi( xmlNodePtr pi ) { dom_pi *This; - HRESULT hr; + xmlnode *node; This = HeapAlloc( GetProcessHeap(), 0, sizeof *This ); if ( !This ) @@ -614,22 +614,15 @@ IUnknown* create_pi( xmlNodePtr pi ) This->lpVtbl = &dom_pi_vtbl; This->ref = 1; - This->node_unk = create_basic_node( pi, (IUnknown*)&This->lpVtbl ); - if(!This->node_unk) + node = create_basic_node( pi, (IUnknown*)&This->lpVtbl ); + if(!node) { HeapFree(GetProcessHeap(), 0, This); return NULL; } - hr = IUnknown_QueryInterface(This->node_unk, &IID_IXMLDOMNode, (LPVOID*)&This->node); - if(FAILED(hr)) - { - IUnknown_Release(This->node_unk); - HeapFree( GetProcessHeap(), 0, This ); - return NULL; - } - /* The ref on This->node is actually looped back into this object, so release it */ - IXMLDOMNode_Release(This->node); + This->node_unk = (IUnknown*)&node->lpInternalUnkVtbl; + This->node = IXMLDOMNode_from_impl(node); return (IUnknown*) &This->lpVtbl; } diff --git a/dlls/msxml3/text.c b/dlls/msxml3/text.c index 0e231994d69..58de405c321 100644 --- a/dlls/msxml3/text.c +++ b/dlls/msxml3/text.c @@ -772,7 +772,7 @@ static const struct IXMLDOMTextVtbl domtext_vtbl = IUnknown* create_text( xmlNodePtr text ) { domtext *This; - HRESULT hr; + xmlnode *node; This = HeapAlloc( GetProcessHeap(), 0, sizeof *This ); if ( !This ) @@ -781,22 +781,15 @@ IUnknown* create_text( xmlNodePtr text ) This->lpVtbl = &domtext_vtbl; This->ref = 1; - This->node_unk = create_basic_node( text, (IUnknown*)&This->lpVtbl ); - if(!This->node_unk) + node = create_basic_node( text, (IUnknown*)&This->lpVtbl ); + if(!node) { HeapFree(GetProcessHeap(), 0, This); return NULL; } - hr = IUnknown_QueryInterface(This->node_unk, &IID_IXMLDOMNode, (LPVOID*)&This->node); - if(FAILED(hr)) - { - IUnknown_Release(This->node_unk); - HeapFree( GetProcessHeap(), 0, This ); - return NULL; - } - /* The ref on This->node is actually looped back into this object, so release it */ - IXMLDOMNode_Release(This->node); + This->node_unk = (IUnknown*)&node->lpInternalUnkVtbl; + This->node = IXMLDOMNode_from_impl(node); return (IUnknown*) &This->lpVtbl; }