aboutsummaryrefslogtreecommitdiff
path: root/src/vec.hff
diff options
context:
space:
mode:
Diffstat (limited to 'src/vec.hff')
-rw-r--r--src/vec.hff8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/vec.hff b/src/vec.hff
index 8f794c9..fb44196 100644
--- a/src/vec.hff
+++ b/src/vec.hff
@@ -25,6 +25,14 @@ struct Vec<T> {
vec.len = 0;
vec.cap = 0;
}
+
+ fn compact(vec *Vec) [#]T {
+ if vec.dat {
+ vec.cap = vec.len;
+ vec.dat = realloc(vec.dat, vec.cap * sizeof T);
+ }
+ return vec.dat[0::vec.len];
+ }
}
defmacro vec_each(x, i, v, ...body) [