Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig standard library. Public Function

reset

Public Function
std.heap.memory_pool.Extra.reset
pub fn reset(pool: *Pool, allocator: Allocator, mode: ResetMode) bool

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.

Params

File

heap/memory_pool.zig:98
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;
        }