std.heap.ArenaAllocator: fix incorrectly activating safety check

This commit is contained in:
Andrew Kelley 2018-02-12 03:21:18 -05:00
parent 227ead54be
commit ec0846a00f

View File

@ -232,7 +232,7 @@ pub const ArenaAllocator = struct {
var cur_node = if (self.buffer_list.last) |last_node| last_node else try self.createNode(0, n + alignment); var cur_node = if (self.buffer_list.last) |last_node| last_node else try self.createNode(0, n + alignment);
while (true) { while (true) {
const cur_buf = cur_node.data[@sizeOf(BufNode)..]; const cur_buf = cur_node.data[@sizeOf(BufNode)..];
const addr = @ptrToInt(&cur_buf[self.end_index]); const addr = @ptrToInt(cur_buf.ptr) + self.end_index;
const rem = @rem(addr, alignment); const rem = @rem(addr, alignment);
const march_forward_bytes = if (rem == 0) 0 else (alignment - rem); const march_forward_bytes = if (rem == 0) 0 else (alignment - rem);
const adjusted_index = self.end_index + march_forward_bytes; const adjusted_index = self.end_index + march_forward_bytes;