From ffc8068a74cca75a66296e8bec06d1ef47d7c830 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Thu, 19 Dec 2024 08:44:53 +0000 Subject: Introduce and implement vec_t A vec_t is a dynamic array, separate to a buffer. Should make it easier to distinguish purposes using these two data types. --- lib.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lib.h') diff --git a/lib.h b/lib.h index bf6181b..4fb390e 100644 --- a/lib.h +++ b/lib.h @@ -34,4 +34,16 @@ typedef struct Buffer } buffer_t; buffer_t *buffer_init_str(const char *name, const char *str, size_t str_size); + +typedef struct +{ + u64 size, capacity; + u8 *data; +} vec_t; + +void vec_append(vec_t *vec, void *ptr, u64 size); +void vec_ensure(vec_t *vec, u64 abs_size); +void vec_ensure_free(vec_t *vec, u64 rel_size); +void vec_free(vec_t *vec); + #endif -- cgit v1.2.3-13-gbd6f