NAME
buffer_wpeek, buffer_wseek - peek/seek into a writing I/O buffer
SYNOPSIS
#include <limb/buffer.h>
void buffer_wpeek(buffer *buf, struct iovec v[2]) size_t buffer_wseek(buffer *buf, size_t len)
DESCRIPTION
The buffer_wpeek
() macro allows to peek into a writing buffer's available
space. The array of vectors pointed by v
will be set to the available space
inside the memory of the buffer pointed by buf
currently unused (and which
could therefore can be written into).
The buffer_wseek
() macro will update the internals of the buffer pointed by
buf
to add the next len
bytes of data from its internal memory space.
Because a buffer's internal memory is kept as a circular buffer (see
cbuffer.h(0) for more), the data might not be stored as a continuous block
and requires a couple of vectors to possibly get the full space. Note than it
is possible the second vector will be set to zero if not needed, however v
should always point to an array of 2 elements.
Typically, one would use buffer_wpeek
() to get the locations where to write
data, and after all went well use buffer_wseek
() to have said data
"incorporated" into the buffer.
RETURN VALUE
The buffer_wseek
() function returns the amount of bytes in use by which its
internal buffer grew, which may be less than len
(even 0 if the buffer was
full).