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.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 49 insertions(+), 6 deletions(-) (limited to 'buf.c') diff --git a/buf.c b/buf.c index ac7e83a..04c4d70 100644 --- a/buf.c +++ b/buf.c @@ -114,6 +114,12 @@ int bbuf_realloc(bbuf *buf, int size) return ret; } +int bbuf_reduce(bbuf *buf) +{ + printf("Not implemented\n"); + return -1; +} + //increase buffer for size int bbuf_inc(bbuf *a, char *b, int size) @@ -131,6 +137,48 @@ int bbuf_dec(bbuf *a, char *b, int size) } + +int bbuf_concat(bbuf *a, bbuf *b) +{ + printf("Not implemented\n"); + return -1; +} + +int bbuf_size(bbuf *a) +{ + if (a == NULL) + { + return -1; + } + + //return used size + return a->buf_size; +} + +int bbuf_print(bbuf *a) +{ + int i; + + if (NULL == a) + { + return -1; + } + + for (i=0;ibuf_size;i++) + { + char ch = a->buf[i]; + if (isalpha(ch)) + { + printf("%c",ch); + } else + { + printf("."); + } + } + + return 0; +} + //free buffer void bbuf_free(bbuf *buf) { @@ -145,12 +193,7 @@ void bbuf_free(bbuf *buf) buf->buf = NULL; memset(buf, 0, sizeof(bbuf)); free(buf); + buf = NULL; } } -int bbuf_concat(bbuf *a, bbuf *b) -{ - printf("Not implemented\n"); - return -1; -} - -- cgit v1.2.3