Re: Using XML_GetBuffer/XML_ParseBuffer
"James Whetstone" <[email protected]>
| Newsgroups | gmane.text.xml.expat.general |
|---|---|
| Message-ID | <002601c6df60$ed0dd900$6401a8c0@crankshaft> |
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" <[email protected]> To: "Karl Waclawek" <[email protected]> Cc: <[email protected]> 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" <[email protected]> > To: "James Whetstone" <[email protected]> > Cc: <[email protected]> > 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 > [email protected] > http://mail.libexpat.org/mailman/listinfo/expat-discuss