From 03bfeedc5f4c04c20764c8a9a58bd02604f27b2c Mon Sep 17 00:00:00 2001 From: FreeArtMan Date: Tue, 27 Feb 2018 22:32:49 +0000 Subject: Created circular buffer --- buf.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'buf.h') diff --git a/buf.h b/buf.h index 99872ef..4db4f62 100644 --- a/buf.h +++ b/buf.h @@ -4,10 +4,11 @@ #include #include #include +#include typedef struct bbuf { - int size; - int buf_size; + int size; //total size + int buf_size; //used size char *buf; } bbuf; @@ -25,6 +26,8 @@ bbuf *bbuf_copy(bbuf *buf); int bbuf_get(bbuf *buf, char **val, int *size); //resize buffer int bbuf_realloc(bbuf *buf, int size); +//set to minimal size +int bbuf_reduce(bbuf *buf); //increase buffer for size int bbuf_inc(bbuf *a, char *b, int size); //decrease buffer for size @@ -34,6 +37,10 @@ void bbuf_free(bbuf *buf); int bbuf_concat(bbuf *a, bbuf *b); +int bbuf_size(bbuf *a); + +int bbuf_print(bbuf *a); + void bbuf_free(bbuf *buf); #endif \ No newline at end of file -- cgit v1.2.3