[Expat-discuss] Pull API Status?

Moore, Dave dmoore at viefinancial.com
Tue Mar 11 13:42:04 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.  

These kind of issues seem to be philosophical - who pays in complexity for
improved performance - the library or the user?  Since I've been here all of
5 hours, I'll defer to others on this list for the choice that's consistent
with expat philosophy.

Thanks,
Dave




More information about the Expat-discuss mailing list