ArrayList
The
std.ArrayList
is commonly used throughout Zig, and serves as a buffer that can change in
size. std.ArrayList(T)
is similar to C++‘s std::vector<T>
and Rust’s
Vec<T>
. The deinit()
method frees all of the ArrayList’s memory. The memory
can be read from and written to via its slice field - .items
.
Here we will introduce the usage of the testing allocator. This is a special allocator that only works in tests and can detect memory leaks. In your code, use whatever allocator is appropriate.