Re: Using XML_GetBuffer/XML_ParseBuffer

Karl Waclawek <[email protected]>
Newsgroups gmane.text.xml.expat.general
Message-ID <[email protected]>
James Whetstone wrote:
> So I stepped through the code to see what happens to unused fragments, 
> and it leaves the fragments in the buffer.  From what I can tell, 
> instead of moving the offset of the input buffer, XML_GetBuffer is 
> intended to be called each time new input is to be accepted.
Yes.
> It then allocates a new (larger) buffer, memcpys the fragment from the 
> old buffer to the new buffer and then frees the old buffer.
No, only if the requested length plus the unprocessed fragment exceeds 
the size of the current buffer, otherwise
the unused fragment is simply moved to the beginning of the buffer.
> I'd like to avoid this by simple moving the input buffer's offset to 
> the a end of the fragment and NOT calling XML_GetBuffer to avoid the 
> extran memory allocation.  Any suggestions?
>
Your suggestion in your other message is good - requesting a larger 
buffer on the first call to XML_GetBuffer - should
reduce or eliminate new memory allocations.

Karl
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.