Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kladskull/buffer_manager
C Buffer Manager
https://github.com/kladskull/buffer_manager
Last synced: about 2 months ago
JSON representation
C Buffer Manager
- Host: GitHub
- URL: https://github.com/kladskull/buffer_manager
- Owner: kladskull
- License: mit
- Created: 2015-03-09T18:20:48.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-03-10T00:43:35.000Z (almost 10 years ago)
- Last Synced: 2024-05-02T02:56:26.553Z (8 months ago)
- Language: C
- Size: 141 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# C Buffer Manager
A tool set for managing large buffers. Currently it handles creating the buffer,
appending to the buffer, as well as destroying the buffer. More features may, or
may not be added down the road.Ultimately I wrote this to make things easier for me when managing a large
amount of buffer "chunks" returned from a buffered file handle. I use this for
my recv() calls when dealing with sockets.Pretty simple to use, just include "buffer.h" and copy the code below, or
better, just check out buffer_example.c.```
// create the buffer container
buffer_data *buff;
buff = buffer_init(64); // make the initial size anything you want.
// If things went well, we will have a buffer!
if (buff != NULL) {
ssize_t rtval = 0;
int i;// original string
for (i = 1; i < 100; ++i) {
fprintf(stdout, "String: |%s|\n\n", buff->content);
rtval = buffer_append(buff, "ABCDEFGH");
if (rtval < 1) {
fprintf(stderr, "Error appending, stopping!\n");
exit(1);
} else {
fprintf(stdout, "appended %zd bytes of data\n", rtval);
}
}
}
// free the buffer
buffer_destroy(buff);
```## License
MIT license. Copyright © 2015 Mike Curry