Robert Collins wrote:
> I have a small question:
> What if I want to pull the first 32K out of a 64K IOBuf, and send that
> somewhere in squid. Then I want to send a locally generated 12Kb buff,
> and then the rest of the 64Kb buffer. Do I need to memcpy the 32Kb
> buffers? Can the 12Kb be a static buffer? (marked in some fashion as not
> needing free - or is this just plain bad? )
Not as the API is written today, and not the way it is going either.
You write the first 32KB of the IOBUF, then write your IOBUF with that
12KB of data, and finally write the rest of the first IOBUF.
IOBUF *first = ... /* the 64KB data buffer */
IOBUF *second = ... /* your 12KB data */
/* write 32768 bytes starting at 0 from IOBUF first */
ncomm_write(fh, first, 0, 32768, your_callback, your_cbdata);
/* write the content of IOBUF second */
ncomm_write(fh, second, 0, 0, your_callback, your_cbdata);
/* write the rest of IOBUF first, starting 32768 bytes into */
ncomm_write(fh, first, 32768, 0, your_callback, your_cbdata);
What Alex suggested (and which might be how it actually ends up, at
least for ncomm_write and callbacks) is that the offset and size
parameters are moved into an optional "range" specification. This makes
life easier for the (probably) most common operation writing a whole
IOBUF as it is.
/Henrik
Received on Tue Feb 20 2001 - 15:45:43 MST
This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:13:33 MST