From 01fe9f2eeab8b54487a4673e74851160adb1718d Mon Sep 17 00:00:00 2001 From: Fabrice Date: Mon, 2 Mar 2026 12:43:25 +0100 Subject: working on array implementation --- src/array.cc | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src/array.cc') diff --git a/src/array.cc b/src/array.cc index 0238c05..7c8cc19 100644 --- a/src/array.cc +++ b/src/array.cc @@ -1,9 +1,27 @@ #ifndef ARRAY_CC #define ARRAY_CC -template +#include "memory.cc" + +#define ARRAY_INIT 4 +#define ARRAY_GROWTH 2 + +template struct Array { - + Slice buffer; + const Allocator* allocator; }; +#define array_init(T, allocator) Array{Slice{}, allocator} + +template +void array_deinit(Array* array) { + assert(array != nullptr); + + if(unlikely(array->allocator == nullptr)) return; + + slice_deallocate(array->allocator, &array->buffer); + array->allocator = nullptr; +} + #endif -- cgit v1.2.3