summaryrefslogtreecommitdiff
path: root/buf.h
diff options
context:
space:
mode:
authorFreeArtMan <dos21h@gmail.com>2018-02-27 22:32:49 +0000
committerFreeArtMan <dos21h@gmail.com>2018-02-27 22:32:49 +0000
commit03bfeedc5f4c04c20764c8a9a58bd02604f27b2c (patch)
tree7ab09ac16649d80ca9e6397fc1b19aa8e184e2db /buf.h
parenta8b9b15b4f02ce3c6c7eac0d9393c44cb3fc668d (diff)
downloadlibbuf-03bfeedc5f4c04c20764c8a9a58bd02604f27b2c.tar.gz
libbuf-03bfeedc5f4c04c20764c8a9a58bd02604f27b2c.zip
Created circular buffer
Diffstat (limited to 'buf.h')
-rw-r--r--buf.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/buf.h b/buf.h
index 99872ef..4db4f62 100644
--- a/buf.h
+++ b/buf.h
@@ -4,10 +4,11 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <ctype.h>
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