Skip to content

Commit aa303e8

Browse files
committed
Add free(::XMLNode) and free(::XMLElement)
1 parent e087f7e commit aa303e8

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/clib.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ _xcopystr(p::Xstr) = (r = bytestring(p); _xmlfree(p); r)
5252
@lx2func xmlNewText
5353
@lx2func xmlNewCDataBlock
5454
@lx2func xmlSetProp
55+
@lx2func xmlFreeNode
5556

5657
# functions for documents
5758

src/nodes.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ has_children(nd::XMLNode) = (nd._struct.children != nullptr)
145145
# whether it is a white-space only text node
146146
is_blanknode(nd::XMLNode) = bool(ccall(xmlIsBlankNode, Cint, (Xptr,), nd.ptr))
147147

148+
function free(nd::XMLNode)
149+
ccall(xmlFreeNode, Void, (Ptr{Void},), nd.ptr)
150+
nd.ptr = nullptr
151+
end
148152

149153
# iteration over children
150154

@@ -207,6 +211,8 @@ content(x::XMLElement) = content(x.node)
207211
Base.string(x::XMLElement) = string(x.node)
208212
Base.show(io::IO, x::XMLElement) = show(io, x.node)
209213

214+
free(x::XMLElement) = free(x.node)
215+
210216
# attribute access
211217

212218
function attribute(x::XMLElement, name::String; required::Bool=false)

0 commit comments

Comments
 (0)