pub fn reset(pool: *Pool, allocator: Allocator, mode: ResetMode) bool 98
99
100
101
102
103
104
105
106
107
108
109 pub fn reset(pool: *Pool, allocator: Allocator, mode: ResetMode) bool {
// TODO: Potentially store all allocated objects in a list as well, allowing to
// just move them into the free list instead of actually releasing the memory.
var arena = pool.arena_state.promote(allocator);
defer pool.arena_state = arena.state;
const reset_successful = arena.reset(mode);
pool.free_list = .{};
return reset_successful;
}
Resets the memory pool and destroys all allocated items. This can be used to batch-destroy all objects without invalidating the memory pool.
The function will return whether the reset operation was successful or not. If the reallocation failed
falseis returned. The pool will still be fully functional in that case, all memory is released. Future allocations just might be slower.NOTE: If
modeisfree_all, the function will always returntrue.