Fix incorrect buffer slicing in stack list deinit

This commit is contained in:
kayomn 2023-06-04 01:34:21 +00:00
parent 306e085d1b
commit d4fd1bfb43
1 changed files with 2 additions and 2 deletions

View File

@ -52,7 +52,7 @@ pub fn Stack(comptime Value: type) type {
return;
}
io.deallocate(allocator, self.values);
io.deallocate(allocator, self.values.ptr[0 .. self.capacity]);
self.values = &.{};
self.capacity = 0;
@ -132,7 +132,7 @@ pub fn Stack(comptime Value: type) type {
pub fn push_all(self: *Self, allocator: io.Allocator, values: []const Value) io.AllocationError!void {
const new_length = self.values.len + values.len;
if (new_length >= self.capacity) {
if (new_length > self.capacity) {
try self.grow(allocator, values.len + values.len);
}