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.
This commit is contained in:
2024-12-19 08:44:53 +00:00
parent 2a4d7addae
commit ffc8068a74
2 changed files with 47 additions and 3 deletions

12
lib.h
View File

@@ -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