Skip to content

Commit 156f06d

Browse files
committed
std.heap.rawCAlloc: avoid unecessary @Alignof
This was causing @Alignof to panic on FreeBSD, NetBSD and DragonflyBSD x86_64 arch, as their system malloc returns memory aligned at 8 bytes for len <= 8.
1 parent e3d3964 commit 156f06d

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

lib/std/heap.zig

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,7 @@ fn rawCAlloc(
181181
) ?[*]u8 {
182182
_ = ret_addr;
183183
assert(log2_ptr_align <= comptime std.math.log2_int(usize, @alignOf(std.c.max_align_t)));
184-
// TODO: change the language to make @ptrCast also do alignment cast
185-
const ptr = @alignCast(@alignOf(std.c.max_align_t), c.malloc(len));
186-
return @ptrCast(?[*]align(@alignOf(std.c.max_align_t)) u8, ptr);
184+
return @ptrCast([*]u8, c.malloc(len));
187185
}
188186

189187
fn rawCResize(

0 commit comments

Comments
 (0)