| ... | ... | @@ -322,7 +322,7 @@ pub fn resize(self: Allocator, allocation: anytype, new_len: usize) bool { |
| 322 | 322 | if (allocation.len == 0) { |
| 323 | 323 | return false; |
| 324 | 324 | } |
| 325 | | const old_memory = mem.sliceAsBytes(allocation); |
| 325 | const old_memory: []u8 = @ptrCast(@constCast(mem.absorbSentinel(allocation))); |
| 326 | 326 | // I would like to use saturating multiplication here, but LLVM cannot lower it |
| 327 | 327 | // on WebAssembly: https://github.com/ziglang/zig/issues/9660 |
| 328 | 328 | //const new_len_bytes = new_len *| @sizeOf(T); |
| ... | ... | @@ -368,7 +368,7 @@ pub fn remap(self: Allocator, allocation: anytype, new_len: usize) ?@TypeOf(allo |
| 368 | 368 | new_memory.len = new_len; |
| 369 | 369 | return new_memory; |
| 370 | 370 | } |
| 371 | | const old_memory = mem.sliceAsBytes(allocation); |
| 371 | const old_memory: []u8 = @ptrCast(@constCast(mem.absorbSentinel(allocation))); |
| 372 | 372 | // I would like to use saturating multiplication here, but LLVM cannot lower it |
| 373 | 373 | // on WebAssembly: https://github.com/ziglang/zig/issues/9660 |
| 374 | 374 | //const new_len_bytes = new_len *| @sizeOf(T); |
| ... | ... | @@ -420,7 +420,7 @@ pub fn reallocAdvanced( |
| 420 | 420 | return ptr; |
| 421 | 421 | } |
| 422 | 422 | |
| 423 | | const old_byte_slice = mem.sliceAsBytes(old_mem); |
| 423 | const old_byte_slice: []u8 = @ptrCast(@constCast(mem.absorbSentinel(old_mem))); |
| 424 | 424 | const byte_count = math.mul(usize, @sizeOf(T), new_n) catch return error.OutOfMemory; |
| 425 | 425 | // Note: can't set shrunk memory to undefined as memory shouldn't be modified on realloc failure |
| 426 | 426 | if (self.rawRemap(old_byte_slice, .fromByteUnits(slice_info.alignment orelse @alignOf(T)), byte_count, return_address)) |p| { |
| ... | ... | @@ -443,8 +443,7 @@ pub fn reallocAdvanced( |
| 443 | 443 | pub fn free(self: Allocator, memory: anytype) void { |
| 444 | 444 | const slice_info = @typeInfo(@TypeOf(memory)).pointer; |
| 445 | 445 | comptime assert(slice_info.size == .slice); |
| 446 | | const mem_with_sent = memory[0 .. memory.len + @intFromBool(slice_info.sentinel() != null)]; |
| 447 | | const bytes: []u8 = @ptrCast(@constCast(mem_with_sent)); |
| 446 | const bytes: []u8 = @ptrCast(@constCast(mem.absorbSentinel(memory))); |
| 448 | 447 | if (bytes.len == 0) return; |
| 449 | 448 | @memset(bytes, undefined); |
| 450 | 449 | self.rawFree(bytes, .fromByteUnits(slice_info.alignment orelse @alignOf(slice_info.child)), @returnAddress()); |