logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

Re: Using XML_GetBuffer/XML_ParseBuffer: msg#00013

Subject: Re: Using XML_GetBuffer/XML_ParseBuffer
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


<Prev in Thread] Current Thread [Next in Thread>