[Expat-discuss] Proposal for XML_ParserReset() function

David Crowley dcrowley@scitegic.com
Mon, 13 Aug 2001 14:01:54 -0700


---------------------- multipart/mixed attachment

I just posted this into the Patches on sourceforge, but thought I would 
present it here for further discussion and so others may test it/refine 
it.  This functionality is quite important for my application (SOAP server) 
which can parse many thousands of XML documents.  When doing some 
profiling, about 12-15% of the time was being spent in memory allocation 
routines when creating and destroying the Parser object.  I know others 
have asked for this functionality and so I spent some time the past weekend 
looking into this.

David



This is my first cut at adding a XML_ParserReset function.  My idea was to 
reset the parser to a state that was almost identical to what it is after 
XML_ParserCreate() except that any allocated memory is preserved.  As this 
patch is currently, I think it misght still has some potential problems 
with dtdInit() and possibly internalEncoding and setContext().  But for my 
documents/application it seems to work great.  It passes Purify without any 
memory leaks and when parsing 5000 documents, I only get ~40 memory 
allocations instead of ~200,000 :)

The function declartion needed for expat.h:

/* Resets an existing parser to a state comparable to that after
    XML_ParserCreate but preserves any allocated memory. */

XMLPARSEAPI(void)
XML_ParserReset(XML_Parser parser, const XML_Char *encoding);


---------------------- multipart/mixed attachment
A non-text attachment was scrubbed...
Name: reset.diff
Type: application/octet-stream
Size: 5937 bytes
Desc: not available
Url : http://mail.libexpat.org/pipermail-21/expat-discuss/attachments/20010813/83be080c/reset.exe

---------------------- multipart/mixed attachment

---------------------- multipart/mixed attachment--