Design a dynamic array using three values: ptr (pointer to the data), len (number of elements), cap (capacity -- how many elements fit before growing). Pack these into three consecutive i64 values in memory:
fn da_new() i64 {
var da: i64 = alloc(24);
store64(da, 0); // ptr = null
store64(da + 8, 0); // len = 0
store64(da + 16, 0); // cap = 0
return da;
}
fn da_len(da: i64) i64 { return load64(da + 8); }
fn da_get(da: i64, i: i64) i64 {
return load64(load64(da) + i * 8);
}