Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Gxml
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Canek Peláez Valdés
Gxml
Commits
6f03bd2f
Commit
6f03bd2f
authored
12 years ago
by
Richard Schwarting
Browse files
Options
Downloads
Patches
Plain Diff
libxml-2.0.vapi, Attr.vala, Document.vala, Element.vala: stop leaking memory from xmlAttrs
parent
579e7313
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
gxml/Attr.vala
+1
-1
1 addition, 1 deletion
gxml/Attr.vala
gxml/Document.vala
+8
-3
8 additions, 3 deletions
gxml/Document.vala
gxml/Element.vala
+10
-6
10 additions, 6 deletions
gxml/Element.vala
vapi/libxml-2.0.vapi
+3
-0
3 additions, 0 deletions
vapi/libxml-2.0.vapi
with
22 additions
and
10 deletions
gxml/Attr.vala
+
1
−
1
View file @
6f03bd2f
...
...
@@ -68,7 +68,7 @@ namespace GXml {
}
/** Private properties */
private
Xml
.
Attr
*
node
;
internal
Xml
.
Attr
*
node
;
/** Constructors */
internal
Attr
(
Xml
.
Attr
*
node
,
Document
doc
)
{
...
...
This diff is collapsed.
Click to expand it.
gxml/Document.vala
+
8
−
3
View file @
6f03bd2f
...
...
@@ -186,6 +186,8 @@ namespace GXml {
~
Document
()
{
List
<
Xml
.
Node
*>
to_free
=
new
List
<
Xml
.
Node
*>
();
sync_dirty_elements
();
/* we use two separate loops, because freeing
a node frees its descendants, and we might
have a branch with children that might be
...
...
@@ -328,10 +330,11 @@ namespace GXml {
try
{
instream
=
fin
.
read
(
null
);
this
.
from_stream
(
instream
,
can
);
instream
.
close
();
}
catch
(
GLib
.
Error
e
)
{
throw
new
DomError
.
INVALID_DOC
(
e
.
message
);
}
this
.
from_stream
(
instream
,
can
);
}
/**
* Creates a Document from data provided through the InputStream instream.
...
...
@@ -342,13 +345,13 @@ namespace GXml {
// TODO: accept Cancellable
// Cancellable can = new Cancellable ();
InputStreamBox
box
=
{
instream
,
can
};
Xml
.
Doc
*
doc
;
Xml
.
TextReader
reader
=
new
Xml
.
TextReader
.
for_io
((
Xml
.
InputReadCallback
)
_ioread
,
(
Xml
.
InputCloseCallback
)
_ioinclose
,
&
box
,
""
,
null
,
0
);
reader
.
read
();
reader
.
expand
();
Xml
.
Doc
*
doc
=
reader
.
current_doc
();
doc
=
reader
.
current_doc
();
reader
.
close
();
this
.
from_libxml2
(
doc
);
...
...
@@ -393,6 +396,8 @@ namespace GXml {
elem
.
save_attributes
(
tmp_node
);
}
this
.
dirty_elements
=
new
List
<
Element
>
();
// clear the old list
tmp_node
->
free
();
}
}
...
...
This diff is collapsed.
Click to expand it.
gxml/Element.vala
+
10
−
6
View file @
6f03bd2f
...
...
@@ -95,7 +95,7 @@ namespace GXml {
if
(
this
.
_attributes
==
null
)
{
this
.
owner_document
.
dirty_elements
.
append
(
this
);
this
.
_attributes
=
new
HashTable
<
string
,
Attr
>
(
GLib
.
str_hash
,
GLib
.
str_equal
);
// TODO: make sure other HashTables have appropriate hash, equal functions
// TODO: make sure other HashTables have appropriate hash, equal functions
for
(
Xml
.
Attr
*
prop
=
base
.
node
->
properties
;
prop
!=
null
;
prop
=
prop
->
next
)
{
attr
=
new
Attr
(
prop
,
this
.
owner_document
);
...
...
@@ -144,16 +144,21 @@ namespace GXml {
}
// Go through the GXml table of attributes for this element and add corresponding libxml2 ones
foreach
(
string
propname
in
this
.
attributes
.
get_keys
())
{
attr
=
this
.
attributes
.
lookup
(
propname
);
foreach
(
string
propname
in
this
.
_attributes
.
get_keys
())
{
attr
=
this
.
_attributes
.
lookup
(
propname
);
Xml
.
Attr
*
saved_attr
;
if
(
attr
.
namespace
_uri
!=
null
||
attr
.
prefix
!=
null
)
{
// I hate namespace handling between libxml2 and DOM Level 2/3 Core!
ns
=
tmp_node
->
new_ns
(
attr
.
namespace
_uri
,
attr
.
prefix
);
this
.
node
->
set_ns_prop
(
ns
,
propname
,
attr
.
node_value
);
saved_attr
=
this
.
node
->
set_ns_prop
(
ns
,
propname
,
attr
.
node_value
);
}
else
{
this
.
node
->
set_prop
(
propname
,
attr
.
node_value
);
saved_attr
=
this
.
node
->
set_prop
(
propname
,
attr
.
node_value
);
}
// Replace the old out-of-tree attr with the newly allocated one in the tree, that way xmlFreeDoc can clean up correctly
attr
.
node
->
free
();
attr
.
node
=
saved_attr
;
}
}
}
...
...
@@ -214,7 +219,6 @@ namespace GXml {
this
.
attributes
.
replace
(
name
,
attr
);
// TODO: replace wanted 'owned', look up what to do
}
/**
* Remove the attribute named name from this element.
...
...
This diff is collapsed.
Click to expand it.
vapi/libxml-2.0.vapi
+
3
−
0
View file @
6f03bd2f
...
...
@@ -277,6 +277,9 @@ namespace Xml {
public
Ns
*
ns
;
public
AttributeType
atype
;
[
CCode
(
cname
=
"xmlFreeProp"
)]
public
int
free
();
[
CCode
(
cname
=
"xmlRemoveProp"
)]
public
int
remove
();
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment