[Expat-discuss] Using XML_GetBuffer/XML_ParseBuffer
James Whetstone
jameswhetstone at comcast.net
Sun Sep 24 00:38:00 CEST 2006
So I found the easiest and maybe the best way to prevent additional memory
allocations is to initially create a buffer that is double the size of the
TCP input buffer. For example, I create a buffer using
XML_GetBuffer(parser, 8192) and then code the rest of the program as if the
buffer is 4096 bytes. So subsequent calls to XML_GetBuffer are called with
a buffer size of 4096.
---James
----- Original Message -----
From: "James Whetstone" <jameswhetstone at comcast.net>
To: "Karl Waclawek" <karl at waclawek.net>
Cc: <expat-discuss at libexpat.org>
Sent: Saturday, September 23, 2006 2:58 PM
Subject: Re: [Expat-discuss] Using XML_GetBuffer/XML_ParseBuffer
> 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. It then allocates a new
> (larger) buffer, memcpys the fragment from the old buffer to the new
> buffer
> and then frees the old 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?
>
> ---James
>
> ----- Original Message -----
> From: "Karl Waclawek" <karl at waclawek.net>
> To: "James Whetstone" <jameswhetstone at comcast.net>
> Cc: <expat-discuss at libexpat.org>
> Sent: Saturday, September 23, 2006 1:29 PM
> Subject: Re: [Expat-discuss] Using XML_GetBuffer/XML_ParseBuffer
>
>
>> James Whetstone wrote:
>>> Another question along the same lines is whether or not I even need to
>>> worry about overwriting left over data in the XML Buffer. I assumed
>>> there would sometimes be some left over data of a XML fragment in the
>>> buffer, but maybe that isn't the case.
>>>
>>>
>> If I remember correctly, Expat buffers any unused fragments. So you
>> should
>> not have to worry.
>>
>> Karl
>
> _______________________________________________
> Expat-discuss mailing list
> Expat-discuss at libexpat.org
> http://mail.libexpat.org/mailman/listinfo/expat-discuss
More information about the Expat-discuss
mailing list