fifo_buffer: add functions _capacity() and _available()
This commit is contained in:
parent
07067f8b95
commit
a85af593f1
@ -66,6 +66,22 @@ fifo_buffer_free(struct fifo_buffer *buffer)
|
||||
g_free(buffer);
|
||||
}
|
||||
|
||||
size_t
|
||||
fifo_buffer_capacity(const struct fifo_buffer *buffer)
|
||||
{
|
||||
assert(buffer != NULL);
|
||||
|
||||
return buffer->size;
|
||||
}
|
||||
|
||||
size_t
|
||||
fifo_buffer_available(const struct fifo_buffer *buffer)
|
||||
{
|
||||
assert(buffer != NULL);
|
||||
|
||||
return buffer->end - buffer->start;
|
||||
}
|
||||
|
||||
void
|
||||
fifo_buffer_clear(struct fifo_buffer *buffer)
|
||||
{
|
||||
|
@ -62,6 +62,19 @@ fifo_buffer_new(size_t size);
|
||||
void
|
||||
fifo_buffer_free(struct fifo_buffer *buffer);
|
||||
|
||||
/**
|
||||
* Return the capacity of the buffer, i.e. the size that was passed to
|
||||
* fifo_buffer_new().
|
||||
*/
|
||||
size_t
|
||||
fifo_buffer_capacity(const struct fifo_buffer *buffer);
|
||||
|
||||
/**
|
||||
* Return the number of bytes currently stored in the buffer.
|
||||
*/
|
||||
size_t
|
||||
fifo_buffer_available(const struct fifo_buffer *buffer);
|
||||
|
||||
/**
|
||||
* Clears all data currently in this #fifo_buffer object. This does
|
||||
* not overwrite the actuall buffer; it just resets the internal
|
||||
|
Loading…
Reference in New Issue
Block a user