From 14fb4ab4a19bbb281f614ef93a009a07e86ebf14 Mon Sep 17 00:00:00 2001 From: Ekaitz Zarraga Date: Sun, 3 Mar 2024 22:19:15 +0100 Subject: buffer: simplify api removing booleans and make fixed static --- src/buffer.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'src/buffer.c') diff --git a/src/buffer.c b/src/buffer.c index dde1d90..a3ee649 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -1,15 +1,13 @@ #include "buffer.h" #include #include +#include -bool init_growable_buffer(growable_buffer *buffer) { +void init_growable_buffer(growable_buffer *buffer) { buffer->size = GROW_SIZE; buffer->used = 0; buffer->content = malloc(GROW_SIZE); - if (!buffer->content) { - return false; - } - return true; + assert( buffer->content != 0 ); } char* grow_growable_buffer(growable_buffer *buffer, size_t at_least) { @@ -46,14 +44,8 @@ void free_growable_buffer(growable_buffer *buffer) { -bool init_fixed_buffer(fixed_buffer *buffer, char *orig) { +void init_fixed_buffer(fixed_buffer *buffer, char *orig) { buffer->content = orig; buffer->size = strlen(orig); - return buffer->content != NULL; -} - -void free_fixed_buffer(fixed_buffer *buffer) { - free(buffer->content); - buffer->content = NULL; - buffer->size = 0; + assert( buffer->content != NULL ); } -- cgit v1.2.3