diff options
| author | Ethan Werner <mail@ethanwerner.com> | 2026-06-09 01:17:41 +0400 |
|---|---|---|
| committer | Ethan Werner <mail@ethanwerner.com> | 2026-06-09 01:17:41 +0400 |
| commit | 96ecf29e8be977f51f351308ef2c7c492bb829aa (patch) | |
| tree | c664aa61262e6f7627a732f0e4fbb84281b99952 /example/buffer.c | |
| parent | f6a144987cc403de8ad6bddd055f756120f8d405 (diff) | |
refactor
Diffstat (limited to 'example/buffer.c')
| -rw-r--r-- | example/buffer.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/example/buffer.c b/example/buffer.c new file mode 100644 index 0000000..35237b2 --- /dev/null +++ b/example/buffer.c @@ -0,0 +1,22 @@ +// buffer.c - Example usage of buffer.h dynamic buffer + +#define BUFFER_IMPLEMENTATION +#include "../include/buffer.h" + +#include <inttypes.h> +#include <stdio.h> +#include <stdlib.h> + +int main(void) { + void *buf = buffer_malloc(10, sizeof(int)); + if (!buf) { + fprintf(stderr, "Failed to allocate buffer\n"); + return 1; + } + + printf("capacity: %" PRIu64 "\n", buffer_capacity(buf)); + printf("size: %" PRIu64 "\n", buffer_count(buf)); + + buffer_free(buf); + return 0; +} |