summaryrefslogtreecommitdiff
path: root/src/array.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/array.cc')
-rw-r--r--src/array.cc22
1 files changed, 20 insertions, 2 deletions
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<typename T>
+#include "memory.cc"
+
+#define ARRAY_INIT 4
+#define ARRAY_GROWTH 2
+
+template <typename T>
struct Array {
-
+ Slice<T> buffer;
+ const Allocator* allocator;
};
+#define array_init(T, allocator) Array<T>{Slice<T>{}, allocator}
+
+template<typename T>
+void array_deinit(Array<T>* array) {
+ assert(array != nullptr);
+
+ if(unlikely(array->allocator == nullptr)) return;
+
+ slice_deallocate(array->allocator, &array->buffer);
+ array->allocator = nullptr;
+}
+
#endif