diff options
author | FreeArtMan <dos21h@gmail.com> | 2018-02-27 22:32:49 +0000 |
---|---|---|
committer | FreeArtMan <dos21h@gmail.com> | 2018-02-27 22:32:49 +0000 |
commit | 03bfeedc5f4c04c20764c8a9a58bd02604f27b2c (patch) | |
tree | 7ab09ac16649d80ca9e6397fc1b19aa8e184e2db /buf.c | |
parent | a8b9b15b4f02ce3c6c7eac0d9393c44cb3fc668d (diff) | |
download | libbuf-03bfeedc5f4c04c20764c8a9a58bd02604f27b2c.tar.gz libbuf-03bfeedc5f4c04c20764c8a9a58bd02604f27b2c.zip |
Created circular buffer
Diffstat (limited to 'buf.c')
-rw-r--r-- | buf.c | 55 |
1 files changed, 49 insertions, 6 deletions
@@ -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;i<a->buf_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; -} - |