[Expat-discuss] XML_GetBuffer

Susantha Kumara susantha at opensource.lk
Mon Dec 8 23:56:13 EST 2003


Hi Karl,

> -----Original Message-----
> From: Karl Waclawek [mailto:karl at waclawek.net]
> Sent: Thursday, November 20, 2003 8:02 PM
> To: damitha at opensource.lk; expat-discuss at libexpat.org
> Cc: susantha at opensource.lk
> Subject: Re: [Expat-discuss] XML_GetBuffer
> 
> 
> > If someone give me answers to the following two questions it is
> > greatly appreciated.
> > 
> > 
> > My first question is,
> > My application is receiving buffers of varying length and I need
> > to parse them as I receive them. Is it possible to parse these
> > buffers directly without calling XML_GetBuffer function to get
> > a buffer from expat?.
> 
> 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 ?.

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 ?.

> 
> > My second question is,
> > 
> > If the answer to the first question is yes, will the expat
> > delete my buffer?.
> > 
> > I actually tested these and got the answer to the
> > first 'yes' and to the second 'no'. Just asking to confirm that.
> 
> Confirmed.
> 
> 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.
Does XML_ParserReset free those buffers ?.

> 
> Karl
>

Thanks,

Susantha. 



More information about the Expat-discuss mailing list