mirror of
https://github.com/PixelGuys/Cubyz.git
synced 2025-08-04 03:37:59 -04:00
Fix assertion failures with the arena.shrinkAndFree function.
This commit is contained in:
parent
c495e8406c
commit
c978afab50
@ -808,9 +808,9 @@ pub const NeverFailingArenaAllocator = struct { // MARK: NeverFailingArena
|
|||||||
pub fn shrinkAndFree(self: *NeverFailingArenaAllocator) void {
|
pub fn shrinkAndFree(self: *NeverFailingArenaAllocator) void {
|
||||||
const node = self.arena.state.buffer_list.first orelse return;
|
const node = self.arena.state.buffer_list.first orelse return;
|
||||||
const allocBuf = @as([*]u8, @ptrCast(node))[0..node.data];
|
const allocBuf = @as([*]u8, @ptrCast(node))[0..node.data];
|
||||||
const dataSize = @sizeOf(std.SinglyLinkedList(usize).Node) + self.arena.state.end_index;
|
const dataSize = std.mem.alignForward(usize, @sizeOf(std.SinglyLinkedList(usize).Node) + self.arena.state.end_index, @alignOf(std.SinglyLinkedList(usize).Node));
|
||||||
if(self.arena.child_allocator.resize(allocBuf, dataSize)) {
|
if(self.arena.child_allocator.rawResize(allocBuf, std.math.log2(@alignOf(std.SinglyLinkedList(usize).Node)), dataSize, @returnAddress())) {
|
||||||
node.data = @sizeOf(std.SinglyLinkedList(usize).Node) + dataSize;
|
node.data = dataSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user