From 4fa724461e558561402b05bd4eadf8c7b6874556 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 15 Jan 2013 01:17:39 +0100 Subject: util/fifo_buffer: add method _init() --- src/util/fifo_buffer.c | 8 ++++++++ src/util/fifo_buffer.h | 3 +++ 2 files changed, 11 insertions(+) diff --git a/src/util/fifo_buffer.c b/src/util/fifo_buffer.c index 915fb0579..162ddf946 100644 --- a/src/util/fifo_buffer.c +++ b/src/util/fifo_buffer.c @@ -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); diff --git a/src/util/fifo_buffer.h b/src/util/fifo_buffer.h index 49c7f4992..ccea97d86 100644 --- a/src/util/fifo_buffer.h +++ b/src/util/fifo_buffer.h @@ -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. -- cgit v1.2.3