This commit is contained in:
agra
2026-02-11 20:41:43 +02:00
parent 94b0296fd5
commit 9d96f05d3b
13 changed files with 460 additions and 70 deletions

View File

@@ -305,3 +305,24 @@ build_print :: (fmt: string) -> string {
print :: ($fmt: string, args: ..Any) {
#insert build_print(fmt);
}
List :: struct ($T: Type) {
items: [*]T = null;
len: s64 = 0;
cap: s64 = 0;
}
append :: (list: *List($T), item: T) {
if list.len >= list.cap {
new_cap := if list.cap == 0 then 4 else list.cap * 2;
new_items : [*]T = xx malloc(new_cap * size_of(T));
if list.len > 0 {
memcpy(new_items, list.items, list.len * size_of(T));
free(list.items);
}
list.items = new_items;
list.cap = new_cap;
}
list.items[list.len] = item;
list.len += 1;
}