reset
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 false is returned. The pool will still be fully
functional in that case, all memory is released. Future allocations just might
be slower.
NOTE: If mode is free_all, the function will always return true.
Function parameters
Parameters
Type definitions in this namespace
Types
A memory pool that can allocate objects of a single type very quickly.
Functions
- MemoryPool
- A memory pool that can allocate objects of a single type very quickly.
- MemoryPoolAligned
- A memory pool that can allocate objects of a single type very quickly.
- MemoryPoolExtra
- A memory pool that can allocate objects of a single type very quickly.
Error sets in this namespace
Error Sets
Source
Implementation
pub fn reset(pool: *Pool, 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.
const reset_successful = pool.arena.reset(mode);
pool.free_list = null;
return reset_successful;
}