From f277f41d83d450a1f28d350bb7d6da075d1d2741 Mon Sep 17 00:00:00 2001 From: Anshul Gupta Date: Wed, 9 Apr 2025 13:24:53 -0700 Subject: 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 --- src/buffer.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/buffer.h (limited to 'src/buffer.h') 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 +#include + +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 -- cgit v1.2.3