karl at waclawek.net
Tue Dec 9 00:34:45 EST 2003
> > Yes, just use XML_Parse(). However, this will still copy the data
> > to Expat's internal buffer - which Expat creates with XML_GetBuffer().
> > Performance-wise this does not gain you anything.
> > However, if you build Expat with XML_CONTEXT_BYTES undefined then
> > it will parse directly from your buffer, unless there were unparsed
> > data left from the previous buffer - in which case it will still copy
> > all data internally (and this would be the more likely case).
> How can there be unparsed data left from the previous buffer ?. Does
> the parser treat the data unparsed when the remaining bytes at the end
> of a buffer is not enough to generate an event ?.
Yes, if Expat reaches the end of a buffer and there are some data that
are insufficient to generate an event, they are copied over since
they would get lost otherwise.
> One more question : How can I undefine XML_CONTEXT_BYTES ?.
> I commented following line in winconfig.h
> #define XML_CONTEXT_BYTES 1024
> But still the parser working in the same way. If it works fine
> XML_GetInputContext should return NULL ? Am I correct ?.
Yes - as one can see from the source.
Make sure you do a full re-build.
> > Btw, the best approach performance-wise would be if your
> > application could use a buffer created with XML_GetBuffer().
> > That would avoid double copying.
> If we do this does the buffer belong to the application ?. I mean
> memory freeing ?. I suppose not.
Correct, this memory is managed by Expat.
> Does XML_ParserReset free those buffers ?.
I don't remember, but it should not concern you,
as you don't have to manage that memory.
More information about the Expat-discuss