From 35cd6d146829ccc2cc07bb11678098414343a2aa Mon Sep 17 00:00:00 2001 From: Luca A <38193617+lucaato@users.noreply.github.com> Date: Tue, 20 Jun 2023 14:36:59 +0200 Subject: [PATCH] Update circular_buffer.h Added function definition in header files. --- .../circular-buffer/circular_buffer.h | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/exercises/practice/circular-buffer/circular_buffer.h b/exercises/practice/circular-buffer/circular_buffer.h index 9f809d42c..ec13e26d0 100644 --- a/exercises/practice/circular-buffer/circular_buffer.h +++ b/exercises/practice/circular-buffer/circular_buffer.h @@ -1,4 +1,30 @@ #ifndef CIRCULAR_BUFFER_H #define CIRCULAR_BUFFER_H +#include +#include + +typedef int16_t buffer_value_t; +typedef struct circular_buffer_t circular_buffer_t; + +// constructs a new buffer +circular_buffer_t *new_circular_buffer(size_t capacity); + +// read next value from buffer +int16_t read(circular_buffer_t *buffer, buffer_value_t *value); + +// write a value to the buffer +int16_t write(circular_buffer_t *buffer, buffer_value_t value); + +// write a value to the buffer +// overwrites the oldest value if the buffer is already full +int16_t overwrite(circular_buffer_t *buffer, buffer_value_t value); + +// clear the buffer +void clear_buffer(circular_buffer_t *buffer); + +// destroy the entire buffer +// buffer will be a dangling pointer after calling this method on it +void delete_buffer(circular_buffer_t *buffer); + #endif