[Expat-discuss] Pull API Status?

Karl Waclawek karl at waclawek.net
Tue Mar 11 13:45:53 EST 2003


> After looking further into the way that XML_GetNextBuffer() would work,
> there is a "wrinkle" involved when we have a partial token left over from
> the previous buffer.  Since we have to arrange for the leftover bytes to be
> just in front of any new bytes before continuing with our parsing, we have
> some choices:
> 
> 1.  Copy leftover bytes out and into a dynamic buffer, ask the user for
> their new buffer, and then copy both blocks into a contiguous dynamically
> allocated buffer.  Simple for the user, slower for us.
> 
> 2.  Ask the user for a buffer of a certain minimum size, and instruct the
> user to copy their new data into this buffer starting at a certain offset
> into that buffer, leaving us room to shift the old bytes to the beginning of
> the buffer, and allowing for "huge" nodes that span several buffers.  New
> signature:  
> XML_GetNextBuffer(int min_buffer_len,int offset, char **p_new_buffer,int
> *p_new_len);
>   
> 3.  Ask the user to prepend our leftover data for us, effective shifting the
> work that XML_GetBuffer does onto the user.  This will minimize unnecessary
> allocations and copies, but doesn't feel clean to me.  New signature:
> 
> XML_GetNextBuffer(const char *p_old_data,int len_old,data, char
> **p_new_buffer,int *p_new_len);
> 
> 4.  Some combination of the above - that main thing is to allow for and
> protect ourselves against the user re-using the same buffer across calls.  

XML_Parse and XML_ParseBuffer already do that. We just need to
convert them from being supplied a buffer to getting one.
Of course, the devlish details may make it not quite that simple.

Karl



More information about the Expat-discuss mailing list