aboutsummaryrefslogtreecommitdiff
path: root/code/lib/vector.felan
diff options
context:
space:
mode:
Diffstat (limited to 'code/lib/vector.felan')
-rw-r--r--code/lib/vector.felan22
1 files changed, 22 insertions, 0 deletions
diff --git a/code/lib/vector.felan b/code/lib/vector.felan
new file mode 100644
index 0000000..6ad1991
--- /dev/null
+++ b/code/lib/vector.felan
@@ -0,0 +1,22 @@
+@import("operator.felan");
+@import("memory.felan");
+
+vector :: (comptime t:type)->type{
+ return struct {
+ ptr : *t;
+ size : u64;
+ capacity : u64;
+ };
+};
+
+vector_new :: (comptime t:type) -> (vector(t)) {
+ v : vector(t) = undefined;
+ v.ptr = malloc(0,@type_of(v.ptr.*));
+ v.size = 0u64;
+ v.capacity = 0u64;
+ return v;
+};
+
+delete :: (vec:vector(anytype)) -> void {
+ free(vec.ptr);
+};