util/fifo_buffer: add method _init()

This commit is contained in:
Max Kellermann 2013-01-15 01:17:39 +01:00
parent 1e2018ce83
commit 4fa724461e
2 changed files with 11 additions and 0 deletions

View File

@ -58,6 +58,14 @@ fifo_buffer_new(size_t size)
return buffer;
}
void
fifo_buffer_init(struct fifo_buffer *buffer, size_t size)
{
buffer->size = size - (sizeof(*buffer) - sizeof(buffer->buffer));
buffer->start = 0;
buffer->end = 0;
}
static void
fifo_buffer_move(struct fifo_buffer *buffer);

View File

@ -60,6 +60,9 @@ extern "C" {
struct fifo_buffer *
fifo_buffer_new(size_t size);
void
fifo_buffer_init(struct fifo_buffer *buffer, size_t size);
/**
* Change the capacity of the #fifo_buffer, while preserving existing
* data.