Menu

#207 Buildup of ParseEvent in sgml::parseEvent

Script Library
open
nobody
TclXML (91)
5
2012-06-11
2012-06-11
Anonymous
No

If xml::tclparser::parse is called with the final set to 1 (the default), then the '-statevariable' option is not passed into sgml::parseEvent.

As a result sgml::parseEvent will create its own -statevariable called ParseEvent[num]. These variables are not properly cleaned up when xml::tclparser::delete is called, which can build up cruft with repeated parsings.

Here's the script I used to test this:
package require xml

proc parseXml {str_to_parse} {
set xml_parser [::xml::parser]
$xml_parser parse $str_to_parse
$xml_parser free
unset xml_parser
}

set xmlData "<?xml version='1.0'?><response><action id='DoStuff'><state><current>OFF</current><next>ON</next></state></action></response>"

while 1 {
parseXml $xmlData
set sgmlVars [info vars ::sgml::*]
set numSgmlVars [llength $sgmlVars]
puts "sgml vars ($numSgmlVars): $sgmlVars\n"
}

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.