Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
e497ed82
Commit
e497ed82
authored
Oct 11, 2008
by
Michael Karcher
Committed by
Alexandre Julliard
Oct 13, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msxml3: Add an orphan node list to xmlDoc.
parent
0f8950d6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
0 deletions
+73
-0
domdoc.c
dlls/msxml3/domdoc.c
+71
-0
msxml_private.h
dlls/msxml3/msxml_private.h
+2
-0
No files found.
dlls/msxml3/domdoc.c
View file @
e497ed82
...
@@ -39,6 +39,7 @@
...
@@ -39,6 +39,7 @@
#include "dispex.h"
#include "dispex.h"
#include "wine/debug.h"
#include "wine/debug.h"
#include "wine/list.h"
#include "msxml_private.h"
#include "msxml_private.h"
...
@@ -81,10 +82,38 @@ typedef struct _domdoc
...
@@ -81,10 +82,38 @@ typedef struct _domdoc
DispatchEx
dispex
;
DispatchEx
dispex
;
}
domdoc
;
}
domdoc
;
/*
In native windows, the whole lifetime management of XMLDOMNodes is
managed automatically using reference counts. Wine emulates that by
maintaining a reference count to the document that is increased for
each IXMLDOMNode pointer passed out for this document. If all these
pointers are gone, the document is unreachable and gets freed, that
is, all nodes in the tree of the document get freed.
You are able to create nodes that are associated to a document (in
fact, in msxml's XMLDOM model, all nodes are associated to a document),
but not in the tree of that document, for example using the createFoo
functions from IXMLDOMDocument. These nodes do not get cleaned up
by libxml, so we have to do it ourselves.
To catch these nodes, a list of "orphan nodes" is introduced.
It contains pointers to all roots of node trees that are
associated with the document without being part of the document
tree. All nodes with parent==NULL (except for the document root nodes)
should be in the orphan node list of their document. All orphan nodes
get freed together with the document itself.
*/
typedef
struct
_xmldoc_priv
{
typedef
struct
_xmldoc_priv
{
LONG
refs
;
LONG
refs
;
struct
list
orphans
;
}
xmldoc_priv
;
}
xmldoc_priv
;
typedef
struct
_orphan_entry
{
struct
list
entry
;
xmlNode
*
node
;
}
orphan_entry
;
static
inline
xmldoc_priv
*
priv_from_xmlDocPtr
(
xmlDocPtr
doc
)
static
inline
xmldoc_priv
*
priv_from_xmlDocPtr
(
xmlDocPtr
doc
)
{
{
return
doc
->
_private
;
return
doc
->
_private
;
...
@@ -96,7 +125,10 @@ static xmldoc_priv * create_priv(void)
...
@@ -96,7 +125,10 @@ static xmldoc_priv * create_priv(void)
priv
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
*
priv
)
);
priv
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
*
priv
)
);
if
(
priv
)
if
(
priv
)
{
priv
->
refs
=
0
;
priv
->
refs
=
0
;
list_init
(
&
priv
->
orphans
);
}
return
priv
;
return
priv
;
}
}
...
@@ -129,7 +161,14 @@ LONG xmldoc_release(xmlDocPtr doc)
...
@@ -129,7 +161,14 @@ LONG xmldoc_release(xmlDocPtr doc)
TRACE
(
"%d
\n
"
,
ref
);
TRACE
(
"%d
\n
"
,
ref
);
if
(
ref
==
0
)
if
(
ref
==
0
)
{
{
orphan_entry
*
orphan
,
*
orphan2
;
TRACE
(
"freeing docptr %p
\n
"
,
doc
);
TRACE
(
"freeing docptr %p
\n
"
,
doc
);
LIST_FOR_EACH_ENTRY_SAFE
(
orphan
,
orphan2
,
&
priv
->
orphans
,
orphan_entry
,
entry
)
{
xmlFreeNode
(
orphan
->
node
);
HeapFree
(
GetProcessHeap
(),
0
,
orphan
);
}
HeapFree
(
GetProcessHeap
(),
0
,
doc
->
_private
);
HeapFree
(
GetProcessHeap
(),
0
,
doc
->
_private
);
xmlFreeDoc
(
doc
);
xmlFreeDoc
(
doc
);
...
@@ -138,6 +177,38 @@ LONG xmldoc_release(xmlDocPtr doc)
...
@@ -138,6 +177,38 @@ LONG xmldoc_release(xmlDocPtr doc)
return
ref
;
return
ref
;
}
}
HRESULT
xmldoc_add_orphan
(
xmlDocPtr
doc
,
xmlNodePtr
node
)
{
xmldoc_priv
*
priv
=
priv_from_xmlDocPtr
(
doc
);
orphan_entry
*
entry
;
entry
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
*
entry
)
);
if
(
!
entry
)
return
E_OUTOFMEMORY
;
entry
->
node
=
node
;
list_add_head
(
&
priv
->
orphans
,
&
entry
->
entry
);
return
S_OK
;
}
HRESULT
xmldoc_remove_orphan
(
xmlDocPtr
doc
,
xmlNodePtr
node
)
{
xmldoc_priv
*
priv
=
priv_from_xmlDocPtr
(
doc
);
orphan_entry
*
entry
,
*
entry2
;
LIST_FOR_EACH_ENTRY_SAFE
(
entry
,
entry2
,
&
priv
->
orphans
,
orphan_entry
,
entry
)
{
if
(
entry
->
node
==
node
)
{
list_remove
(
&
entry
->
entry
);
HeapFree
(
GetProcessHeap
(),
0
,
entry
);
return
S_OK
;
}
}
return
S_FALSE
;
}
static
inline
domdoc
*
impl_from_IXMLDOMDocument2
(
IXMLDOMDocument2
*
iface
)
static
inline
domdoc
*
impl_from_IXMLDOMDocument2
(
IXMLDOMDocument2
*
iface
)
{
{
return
(
domdoc
*
)((
char
*
)
iface
-
FIELD_OFFSET
(
domdoc
,
lpVtbl
));
return
(
domdoc
*
)((
char
*
)
iface
-
FIELD_OFFSET
(
domdoc
,
lpVtbl
));
...
...
dlls/msxml3/msxml_private.h
View file @
e497ed82
...
@@ -65,6 +65,8 @@ extern BSTR bstr_from_xmlChar( const xmlChar *buf );
...
@@ -65,6 +65,8 @@ extern BSTR bstr_from_xmlChar( const xmlChar *buf );
extern
LONG
xmldoc_add_ref
(
xmlDocPtr
doc
);
extern
LONG
xmldoc_add_ref
(
xmlDocPtr
doc
);
extern
LONG
xmldoc_release
(
xmlDocPtr
doc
);
extern
LONG
xmldoc_release
(
xmlDocPtr
doc
);
extern
HRESULT
xmldoc_add_orphan
(
xmlDocPtr
doc
,
xmlNodePtr
node
);
extern
HRESULT
xmldoc_remove_orphan
(
xmlDocPtr
doc
,
xmlNodePtr
node
);
extern
HRESULT
XMLElement_create
(
IUnknown
*
pUnkOuter
,
xmlNodePtr
node
,
LPVOID
*
ppObj
);
extern
HRESULT
XMLElement_create
(
IUnknown
*
pUnkOuter
,
xmlNodePtr
node
,
LPVOID
*
ppObj
);
extern
HRESULT
XMLElementCollection_create
(
IUnknown
*
pUnkOuter
,
xmlNodePtr
node
,
LPVOID
*
ppObj
);
extern
HRESULT
XMLElementCollection_create
(
IUnknown
*
pUnkOuter
,
xmlNodePtr
node
,
LPVOID
*
ppObj
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment