Write free():
var free_list: i64 = 0;
fn free(ptr: i64) i64 {
var block: i64 = ptr - 8;
store64(block + 8, free_list);
free_list = block;
return 0;
}
Two lines of real work. We write the current list head into the freed block's payload, then make the freed block the new head. It's a linked-list prepend using raw memory.