From a27a3e6ae09e8396584c95a3567b145e86d8bc40 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 24 Feb 2019 17:53:46 +0100 Subject: Fixed CHECK_RESULT macro, use scoped allocator Scoped allocator gives us better performance and cleanup code for error cases is much cleaner --- include/buffer.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'include/buffer.h') diff --git a/include/buffer.h b/include/buffer.h index c45fbde..700ae7b 100644 --- a/include/buffer.h +++ b/include/buffer.h @@ -1,20 +1,19 @@ #ifndef AMALGAM_BUFFER_H #define AMALGAM_BUFFER_H -#include "types.h" -#include "misc.h" +#include "scoped_allocator.h" #define BUFFER_OK 0 #define BUFFER_ALLOC_FAIL -1 typedef struct { + ScopedAllocator *allocator; char* data; usize size; usize capacity; } Buffer; -void buffer_init(Buffer *self); -void buffer_deinit(Buffer *self); +CHECK_RESULT int buffer_init(Buffer *self, ScopedAllocator *allocator, usize initial_capacity); CHECK_RESULT int buffer_append(Buffer *self, void *data, usize size); void* buffer_get(Buffer *self, usize index, usize type_size); -- cgit v1.2.3