From 82eec8b529f2113f19b443446545bad66d3a1547 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Tue, 3 Dec 2024 00:21:42 +0000 Subject: Implement buffer_t functions to make it stretchy --- lib.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib.h') diff --git a/lib.h b/lib.h index 8af0d13..dc844bb 100644 --- a/lib.h +++ b/lib.h @@ -28,9 +28,13 @@ void print_error(const char *handle, size_t row, size_t column, typedef struct Buffer { const char *name; - size_t size; - char data[]; + u64 size, capacity; + u8 data[]; } buffer_t; buffer_t *buffer_init_str(const char *name, const char *str, size_t str_size); +bool buffer_ensure(buffer_t **buffer, u64 expected); +bool buffer_ensure_relative(buffer_t **buffer, u64 expected); +bool buffer_append(buffer_t **buffer, u8 datum); +bool buffer_append_bytes(buffer_t **buffer, u8 *data, u64 size); #endif -- cgit v1.2.3-13-gbd6f