diff --git a/lib/std/heap/general_purpose_allocator.zig b/lib/std/heap/general_purpose_allocator.zig index c23f8dcd79..bf3f9df76d 100644 --- a/lib/std/heap/general_purpose_allocator.zig +++ b/lib/std/heap/general_purpose_allocator.zig @@ -99,7 +99,7 @@ const math = std.math; const assert = std.debug.assert; const mem = std.mem; const Allocator = std.mem.Allocator; -const page_size = std.mem.page_size; +const page_size = std.heap.pageSize(); // TODO: allow this to be runtime known const StackTrace = std.builtin.StackTrace; /// Integer type for pointing to slots in a small allocation @@ -1040,8 +1040,8 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { const bucket_size = bucketSize(size_class); const bucket_bytes = try self.backing_allocator.alignedAlloc(u8, @alignOf(BucketHeader), bucket_size); - const ptr = @as(*BucketHeader, @ptrCast(bucket_bytes.ptr)); - ptr.* = BucketHeader{ + const ptr: *BucketHeader = @ptrCast(bucket_bytes.ptr); + ptr.* = .{ .page = page.ptr, .alloc_cursor = 0, .used_count = 0, diff --git a/lib/std/mem/Allocator.zig b/lib/std/mem/Allocator.zig index 7f3334f1d2..277758501b 100644 --- a/lib/std/mem/Allocator.zig +++ b/lib/std/mem/Allocator.zig @@ -227,7 +227,7 @@ fn allocBytesWithAlignment(self: Allocator, comptime alignment: u29, byte_count: const byte_ptr = self.rawAlloc(byte_count, log2a(alignment), return_address) orelse return Error.OutOfMemory; // TODO: https://github.com/ziglang/zig/issues/4298 @memset(byte_ptr[0..byte_count], undefined); - return @as([*]align(alignment) u8, @alignCast(byte_ptr)); + return @alignCast(byte_ptr); } /// Requests to modify the size of an allocation. It is guaranteed to not move