msxml3: Use the _private element of xmlDoc as pointer.
This commit is contained in:
parent
2cde9f52da
commit
0f8950d646
|
@ -81,6 +81,26 @@ typedef struct _domdoc
|
||||||
DispatchEx dispex;
|
DispatchEx dispex;
|
||||||
} domdoc;
|
} domdoc;
|
||||||
|
|
||||||
|
typedef struct _xmldoc_priv {
|
||||||
|
LONG refs;
|
||||||
|
} xmldoc_priv;
|
||||||
|
|
||||||
|
static inline xmldoc_priv * priv_from_xmlDocPtr(xmlDocPtr doc)
|
||||||
|
{
|
||||||
|
return doc->_private;
|
||||||
|
}
|
||||||
|
|
||||||
|
static xmldoc_priv * create_priv(void)
|
||||||
|
{
|
||||||
|
xmldoc_priv *priv;
|
||||||
|
priv = HeapAlloc( GetProcessHeap(), 0, sizeof (*priv) );
|
||||||
|
|
||||||
|
if(priv)
|
||||||
|
priv->refs = 0;
|
||||||
|
|
||||||
|
return priv;
|
||||||
|
}
|
||||||
|
|
||||||
static xmlDocPtr doparse( char *ptr, int len )
|
static xmlDocPtr doparse( char *ptr, int len )
|
||||||
{
|
{
|
||||||
#ifdef HAVE_XMLREADMEMORY
|
#ifdef HAVE_XMLREADMEMORY
|
||||||
|
@ -97,18 +117,21 @@ static xmlDocPtr doparse( char *ptr, int len )
|
||||||
|
|
||||||
LONG xmldoc_add_ref(xmlDocPtr doc)
|
LONG xmldoc_add_ref(xmlDocPtr doc)
|
||||||
{
|
{
|
||||||
LONG ref = InterlockedIncrement((LONG*)&doc->_private);
|
LONG ref = InterlockedIncrement(&priv_from_xmlDocPtr(doc)->refs);
|
||||||
TRACE("%d\n", ref);
|
TRACE("%d\n", ref);
|
||||||
return ref;
|
return ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
LONG xmldoc_release(xmlDocPtr doc)
|
LONG xmldoc_release(xmlDocPtr doc)
|
||||||
{
|
{
|
||||||
LONG ref = InterlockedDecrement((LONG*)&doc->_private);
|
xmldoc_priv *priv = priv_from_xmlDocPtr(doc);
|
||||||
|
LONG ref = InterlockedDecrement(&priv->refs);
|
||||||
TRACE("%d\n", ref);
|
TRACE("%d\n", ref);
|
||||||
if(ref == 0)
|
if(ref == 0)
|
||||||
{
|
{
|
||||||
TRACE("freeing docptr %p\n", doc);
|
TRACE("freeing docptr %p\n", doc);
|
||||||
|
HeapFree(GetProcessHeap(), 0, doc->_private);
|
||||||
|
|
||||||
xmlFreeDoc(doc);
|
xmlFreeDoc(doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1194,7 +1217,7 @@ static HRESULT domdoc_onDataAvailable(void *obj, char *ptr, DWORD len)
|
||||||
|
|
||||||
xmldoc = doparse( ptr, len );
|
xmldoc = doparse( ptr, len );
|
||||||
if(xmldoc) {
|
if(xmldoc) {
|
||||||
xmldoc->_private = 0;
|
xmldoc->_private = create_priv();
|
||||||
attach_xmlnode(This->node, (xmlNodePtr) xmldoc);
|
attach_xmlnode(This->node, (xmlNodePtr) xmldoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1310,7 +1333,7 @@ static HRESULT WINAPI domdoc_load(
|
||||||
|
|
||||||
if(!filename || FAILED(hr)) {
|
if(!filename || FAILED(hr)) {
|
||||||
xmldoc = xmlNewDoc(NULL);
|
xmldoc = xmlNewDoc(NULL);
|
||||||
xmldoc->_private = 0;
|
xmldoc->_private = create_priv();
|
||||||
attach_xmlnode(This->node, (xmlNodePtr) xmldoc);
|
attach_xmlnode(This->node, (xmlNodePtr) xmldoc);
|
||||||
hr = S_FALSE;
|
hr = S_FALSE;
|
||||||
}
|
}
|
||||||
|
@ -1442,7 +1465,7 @@ static HRESULT WINAPI domdoc_loadXML(
|
||||||
if(!xmldoc)
|
if(!xmldoc)
|
||||||
xmldoc = xmlNewDoc(NULL);
|
xmldoc = xmlNewDoc(NULL);
|
||||||
|
|
||||||
xmldoc->_private = 0;
|
xmldoc->_private = create_priv();
|
||||||
attach_xmlnode( This->node, (xmlNodePtr) xmldoc );
|
attach_xmlnode( This->node, (xmlNodePtr) xmldoc );
|
||||||
|
|
||||||
return hr;
|
return hr;
|
||||||
|
@ -2060,7 +2083,7 @@ HRESULT DOMDocument_create(IUnknown *pUnkOuter, LPVOID *ppObj)
|
||||||
if(!xmldoc)
|
if(!xmldoc)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
xmldoc->_private = 0;
|
xmldoc->_private = create_priv();
|
||||||
|
|
||||||
hr = DOMDocument_create_from_xmldoc(xmldoc, (IXMLDOMDocument2**)ppObj);
|
hr = DOMDocument_create_from_xmldoc(xmldoc, (IXMLDOMDocument2**)ppObj);
|
||||||
if(FAILED(hr))
|
if(FAILED(hr))
|
||||||
|
|
Loading…
Reference in New Issue