Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xinlin-z/ringbb
Ring Byte Buffer in C
https://github.com/xinlin-z/ringbb
auto-resize ring-buffer
Last synced: 5 days ago
JSON representation
Ring Byte Buffer in C
- Host: GitHub
- URL: https://github.com/xinlin-z/ringbb
- Owner: xinlin-z
- License: mit
- Created: 2023-06-29T09:05:52.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-15T12:56:03.000Z (about 1 year ago)
- Last Synced: 2023-12-16T00:47:54.421Z (about 1 year ago)
- Topics: auto-resize, ring-buffer
- Language: C
- Homepage:
- Size: 38.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ringbb
Ring Byte Buffer in pure C, auto resizable, no thread safe, and with
the capability to push(write) the pop(read) data buffer in both sides.
It could then be used flexibly in different scenarios and
with C and C++ respectively.**Interface**
```c
bool rbb_init(ringbb*, size_t);
void rbb_free(ringbb*);
bool rbb_shrink(ringbb*);
bool rbb_push_back(ringbb*, const void*, size_t);
bool rbb_push_front(ringbb*, const void*, size_t);
size_t rbb_pop_front(ringbb*, void*, size_t);
size_t rbb_pop_back(ringbb*, void*, size_t);
```To access ring byte buffer's capacity and size, just visit the member
variable. Suppose `rb` is a pointer to ringbb struct (check
ring_byte_buf.h), capacity is `rb->capacity`, size is `rb->size`.
You can only read them, do not modify them in any case!!**Test on Linux**
```shell
$ make
$ ./testc
$ ./cpptest
```If no FAILED literal, it's passed!
**Example**
`test_ringbb.c` and `cpptest.cpp` can be taken as examples.