diff options
author | 2025-04-09 13:24:53 -0700 | |
---|---|---|
committer | 2025-04-11 00:15:18 -0700 | |
commit | f277f41d83d450a1f28d350bb7d6da075d1d2741 (patch) | |
tree | e197a7de7e26b47cec57a46acdde4b6c74889ad5 /src/buffer.h | |
download | github-mirror-f277f41d83d450a1f28d350bb7d6da075d1d2741.tar.gz github-mirror-f277f41d83d450a1f28d350bb7d6da075d1d2741.tar.zst github-mirror-f277f41d83d450a1f28d350bb7d6da075d1d2741.zip |
Initial Commit
Add cmake github workflow
Install dependencies in gh action
Fix missing directory
Fix compiler errors
Fix group name to gid conversion
Force cjson to statically link
Add header guards to query headers
Add install and cpack to CMakeLists.txt
Add config search and CLI arg parsing
Improve docs for git.c
Fix program continuing on -h flag
Diffstat (limited to 'src/buffer.h')
-rw-r--r-- | src/buffer.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/buffer.h b/src/buffer.h new file mode 100644 index 0000000..ea7c7c3 --- /dev/null +++ b/src/buffer.h @@ -0,0 +1,34 @@ +// +// Created by Anshul Gupta on 4/4/25. +// + +#ifndef BUFFER_H +#define BUFFER_H + +#include <stddef.h> +#include <stdint.h> + +typedef struct { + /// Pointer to the start of the buffer + uint8_t *data; + /// Size of the buffer + size_t len; + /// Size of the allocated buffer + size_t cap; +} buffer_t; + +/// Create a new buffer with the given initial capacity +buffer_t buffer_new(size_t cap); + +/// Free the buffer +void buffer_free(buffer_t buf); + +/// Resize the buffer to the given capacity +/// Does nothing if the new capacity is less than or equal to the +/// current capacity. +void buffer_reserve(buffer_t *buf, size_t cap); + +/// Append data to the buffer +void buffer_append(buffer_t *buf, const void *data, size_t len); + +#endif // BUFFER_H |