Skip to content

Commit e79f8b0

Browse files
committed
Respect arena reset result.
1 parent ec6b295 commit e79f8b0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/std/heap/memory_pool.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,15 @@ pub fn MemoryPoolExtra(comptime Item: type, comptime pool_options: Options) type
126126
.retain_capacity => .retain_capacity,
127127
.retain_with_limit => |limit| ArenaResetMode{ .retain_with_limit = limit * item_size },
128128
};
129-
const reset_successful = pool.arena.reset(arena_mode);
130129
pool.free_list = null;
130+
if (!pool.arena.reset(arena_mode)) return false;
131131
// When the backing arena allocator is being reset to
132132
// a capacity greater than 0, then its internals consists
133133
// of a *single* buffer node of said capacity. This means,
134134
// we can safely pre-heat without causing additional allocations.
135135
const arena_capacity = pool.arena.queryCapacity() / item_size;
136136
if (arena_capacity != 0) pool.preheat(arena_capacity) catch unreachable;
137-
return reset_successful;
137+
return true;
138138
}
139139

140140
/// Creates a new item and adds it to the memory pool.

0 commit comments

Comments
 (0)