| author | |
| committer | |
| log | 783e8ad0319b950a1d42d5a93e4fbb9e9df1be10 |
| tree | 81b12200e10eb03167c48a7115edca5d6dbac4e4 |
| parent | fdae5f5a07c043d9eeefe4933bcfbd03df581fde |
11 files changed, 28 insertions(+), 28 deletions(-)
lib/std/crypto/gimli.zig+2-2| ... | @@ -24,11 +24,11 @@ pub const State = struct { | ... | @@ -24,11 +24,11 @@ pub const State = struct { |
| 24 | const Self = @This(); | 24 | const Self = @This(); |
| 25 | 25 | ||
| 26 | pub fn toSlice(self: *Self) []u8 { | 26 | pub fn toSlice(self: *Self) []u8 { |
| 27 | return @sliceToBytes(self.data[0..]); | 27 | return mem.sliceAsBytes(self.data[0..]); |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | pub fn toSliceConst(self: *Self) []const u8 { | 30 | pub fn toSliceConst(self: *Self) []const u8 { |
| 31 | return @sliceToBytes(self.data[0..]); | 31 | return mem.sliceAsBytes(self.data[0..]); |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | pub fn permute(self: *Self) void { | 34 | pub fn permute(self: *Self) void { |
lib/std/cstr.zig+1-1| ... | @@ -72,7 +72,7 @@ pub const NullTerminated2DArray = struct { | ... | @@ -72,7 +72,7 @@ pub const NullTerminated2DArray = struct { |
| 72 | errdefer allocator.free(buf); | 72 | errdefer allocator.free(buf); |
| 73 | 73 | ||
| 74 | var write_index = index_size; | 74 | var write_index = index_size; |
| 75 | const index_buf = @bytesToSlice(?[*]u8, buf); | 75 | const index_buf = mem.bytesAsSlice(?[*]u8, buf); |
| 76 | 76 | ||
| 77 | var i: usize = 0; | 77 | var i: usize = 0; |
| 78 | for (slices) |slice| { | 78 | for (slices) |slice| { |
lib/std/fifo.zig+4-4| ... | @@ -101,7 +101,7 @@ pub fn LinearFifo( | ... | @@ -101,7 +101,7 @@ pub fn LinearFifo( |
| 101 | } | 101 | } |
| 102 | } | 102 | } |
| 103 | { // set unused area to undefined | 103 | { // set unused area to undefined |
| 104 | const unused = @sliceToBytes(self.buf[self.count..]); | 104 | const unused = mem.sliceAsBytes(self.buf[self.count..]); |
| 105 | @memset(unused.ptr, undefined, unused.len); | 105 | @memset(unused.ptr, undefined, unused.len); |
| 106 | } | 106 | } |
| 107 | } | 107 | } |
| ... | @@ -166,12 +166,12 @@ pub fn LinearFifo( | ... | @@ -166,12 +166,12 @@ pub fn LinearFifo( |
| 166 | { // set old range to undefined. Note: may be wrapped around | 166 | { // set old range to undefined. Note: may be wrapped around |
| 167 | const slice = self.readableSliceMut(0); | 167 | const slice = self.readableSliceMut(0); |
| 168 | if (slice.len >= count) { | 168 | if (slice.len >= count) { |
| 169 | const unused = @sliceToBytes(slice[0..count]); | 169 | const unused = mem.sliceAsBytes(slice[0..count]); |
| 170 | @memset(unused.ptr, undefined, unused.len); | 170 | @memset(unused.ptr, undefined, unused.len); |
| 171 | } else { | 171 | } else { |
| 172 | const unused = @sliceToBytes(slice[0..]); | 172 | const unused = mem.sliceAsBytes(slice[0..]); |
| 173 | @memset(unused.ptr, undefined, unused.len); | 173 | @memset(unused.ptr, undefined, unused.len); |
| 174 | const unused2 = @sliceToBytes(self.readableSliceMut(slice.len)[0 .. count - slice.len]); | 174 | const unused2 = mem.sliceAsBytes(self.readableSliceMut(slice.len)[0 .. count - slice.len]); |
| 175 | @memset(unused2.ptr, undefined, unused2.len); | 175 | @memset(unused2.ptr, undefined, unused2.len); |
| 176 | } | 176 | } |
| 177 | } | 177 | } |
lib/std/fs/watch.zig+1-1| ... | @@ -26,7 +26,7 @@ fn eqlString(a: []const u16, b: []const u16) bool { | ... | @@ -26,7 +26,7 @@ fn eqlString(a: []const u16, b: []const u16) bool { |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | fn hashString(s: []const u16) u32 { | 28 | fn hashString(s: []const u16) u32 { |
| 29 | return @truncate(u32, std.hash.Wyhash.hash(0, @sliceToBytes(s))); | 29 | return @truncate(u32, std.hash.Wyhash.hash(0, mem.sliceAsBytes(s))); |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | const WatchEventError = error{ | 32 | const WatchEventError = error{ |
lib/std/heap.zig+3-3| ... | @@ -283,14 +283,14 @@ const WasmPageAllocator = struct { | ... | @@ -283,14 +283,14 @@ const WasmPageAllocator = struct { |
| 283 | 283 | ||
| 284 | fn getBit(self: FreeBlock, idx: usize) PageStatus { | 284 | fn getBit(self: FreeBlock, idx: usize) PageStatus { |
| 285 | const bit_offset = 0; | 285 | const bit_offset = 0; |
| 286 | return @intToEnum(PageStatus, Io.get(@sliceToBytes(self.data), idx, bit_offset)); | 286 | return @intToEnum(PageStatus, Io.get(mem.sliceAsBytes(self.data), idx, bit_offset)); |
| 287 | } | 287 | } |
| 288 | 288 | ||
| 289 | fn setBits(self: FreeBlock, start_idx: usize, len: usize, val: PageStatus) void { | 289 | fn setBits(self: FreeBlock, start_idx: usize, len: usize, val: PageStatus) void { |
| 290 | const bit_offset = 0; | 290 | const bit_offset = 0; |
| 291 | var i: usize = 0; | 291 | var i: usize = 0; |
| 292 | while (i < len) : (i += 1) { | 292 | while (i < len) : (i += 1) { |
| 293 | Io.set(@sliceToBytes(self.data), start_idx + i, bit_offset, @enumToInt(val)); | 293 | Io.set(mem.sliceAsBytes(self.data), start_idx + i, bit_offset, @enumToInt(val)); |
| 294 | } | 294 | } |
| 295 | } | 295 | } |
| 296 | 296 | ||
| ... | @@ -552,7 +552,7 @@ pub const ArenaAllocator = struct { | ... | @@ -552,7 +552,7 @@ pub const ArenaAllocator = struct { |
| 552 | if (len >= actual_min_size) break; | 552 | if (len >= actual_min_size) break; |
| 553 | } | 553 | } |
| 554 | const buf = try self.child_allocator.alignedAlloc(u8, @alignOf(BufNode), len); | 554 | const buf = try self.child_allocator.alignedAlloc(u8, @alignOf(BufNode), len); |
| 555 | const buf_node_slice = @bytesToSlice(BufNode, buf[0..@sizeOf(BufNode)]); | 555 | const buf_node_slice = mem.bytesAsSlice(BufNode, buf[0..@sizeOf(BufNode)]); |
| 556 | const buf_node = &buf_node_slice[0]; | 556 | const buf_node = &buf_node_slice[0]; |
| 557 | buf_node.* = BufNode{ | 557 | buf_node.* = BufNode{ |
| 558 | .data = buf, | 558 | .data = buf, |
lib/std/io/in_stream.zig+1-1| ... | @@ -235,7 +235,7 @@ pub fn InStream(comptime ReadError: type) type { | ... | @@ -235,7 +235,7 @@ pub fn InStream(comptime ReadError: type) type { |
| 235 | // Only extern and packed structs have defined in-memory layout. | 235 | // Only extern and packed structs have defined in-memory layout. |
| 236 | comptime assert(@typeInfo(T).Struct.layout != builtin.TypeInfo.ContainerLayout.Auto); | 236 | comptime assert(@typeInfo(T).Struct.layout != builtin.TypeInfo.ContainerLayout.Auto); |
| 237 | var res: [1]T = undefined; | 237 | var res: [1]T = undefined; |
| 238 | try self.readNoEof(@sliceToBytes(res[0..])); | 238 | try self.readNoEof(mem.sliceAsBytes(res[0..])); |
| 239 | return res[0]; | 239 | return res[0]; |
| 240 | } | 240 | } |
| 241 | 241 |
lib/std/mem.zig+6-6| ... | @@ -132,7 +132,7 @@ pub const Allocator = struct { | ... | @@ -132,7 +132,7 @@ pub const Allocator = struct { |
| 132 | // their own frame with @Frame(func). | 132 | // their own frame with @Frame(func). |
| 133 | return @intToPtr([*]T, @ptrToInt(byte_slice.ptr))[0..n]; | 133 | return @intToPtr([*]T, @ptrToInt(byte_slice.ptr))[0..n]; |
| 134 | } else { | 134 | } else { |
| 135 | return @bytesToSlice(T, @alignCast(a, byte_slice)); | 135 | return mem.bytesAsSlice(T, @alignCast(a, byte_slice)); |
| 136 | } | 136 | } |
| 137 | } | 137 | } |
| 138 | 138 | ||
| ... | @@ -173,7 +173,7 @@ pub const Allocator = struct { | ... | @@ -173,7 +173,7 @@ pub const Allocator = struct { |
| 173 | return @as([*]align(new_alignment) T, undefined)[0..0]; | 173 | return @as([*]align(new_alignment) T, undefined)[0..0]; |
| 174 | } | 174 | } |
| 175 | 175 | ||
| 176 | const old_byte_slice = @sliceToBytes(old_mem); | 176 | const old_byte_slice = mem.sliceAsBytes(old_mem); |
| 177 | const byte_count = math.mul(usize, @sizeOf(T), new_n) catch return Error.OutOfMemory; | 177 | const byte_count = math.mul(usize, @sizeOf(T), new_n) catch return Error.OutOfMemory; |
| 178 | // Note: can't set shrunk memory to undefined as memory shouldn't be modified on realloc failure | 178 | // Note: can't set shrunk memory to undefined as memory shouldn't be modified on realloc failure |
| 179 | const byte_slice = try self.reallocFn(self, old_byte_slice, Slice.alignment, byte_count, new_alignment); | 179 | const byte_slice = try self.reallocFn(self, old_byte_slice, Slice.alignment, byte_count, new_alignment); |
| ... | @@ -181,7 +181,7 @@ pub const Allocator = struct { | ... | @@ -181,7 +181,7 @@ pub const Allocator = struct { |
| 181 | if (new_n > old_mem.len) { | 181 | if (new_n > old_mem.len) { |
| 182 | @memset(byte_slice.ptr + old_byte_slice.len, undefined, byte_slice.len - old_byte_slice.len); | 182 | @memset(byte_slice.ptr + old_byte_slice.len, undefined, byte_slice.len - old_byte_slice.len); |
| 183 | } | 183 | } |
| 184 | return @bytesToSlice(T, @alignCast(new_alignment, byte_slice)); | 184 | return mem.bytesAsSlice(T, @alignCast(new_alignment, byte_slice)); |
| 185 | } | 185 | } |
| 186 | 186 | ||
| 187 | /// Prefer calling realloc to shrink if you can tolerate failure, such as | 187 | /// Prefer calling realloc to shrink if you can tolerate failure, such as |
| ... | @@ -221,18 +221,18 @@ pub const Allocator = struct { | ... | @@ -221,18 +221,18 @@ pub const Allocator = struct { |
| 221 | // new_n <= old_mem.len and the multiplication didn't overflow for that operation. | 221 | // new_n <= old_mem.len and the multiplication didn't overflow for that operation. |
| 222 | const byte_count = @sizeOf(T) * new_n; | 222 | const byte_count = @sizeOf(T) * new_n; |
| 223 | 223 | ||
| 224 | const old_byte_slice = @sliceToBytes(old_mem); | 224 | const old_byte_slice = mem.sliceAsBytes(old_mem); |
| 225 | @memset(old_byte_slice.ptr + byte_count, undefined, old_byte_slice.len - byte_count); | 225 | @memset(old_byte_slice.ptr + byte_count, undefined, old_byte_slice.len - byte_count); |
| 226 | const byte_slice = self.shrinkFn(self, old_byte_slice, Slice.alignment, byte_count, new_alignment); | 226 | const byte_slice = self.shrinkFn(self, old_byte_slice, Slice.alignment, byte_count, new_alignment); |
| 227 | assert(byte_slice.len == byte_count); | 227 | assert(byte_slice.len == byte_count); |
| 228 | return @bytesToSlice(T, @alignCast(new_alignment, byte_slice)); | 228 | return mem.bytesAsSlice(T, @alignCast(new_alignment, byte_slice)); |
| 229 | } | 229 | } |
| 230 | 230 | ||
| 231 | /// Free an array allocated with `alloc`. To free a single item, | 231 | /// Free an array allocated with `alloc`. To free a single item, |
| 232 | /// see `destroy`. | 232 | /// see `destroy`. |
| 233 | pub fn free(self: *Allocator, memory: var) void { | 233 | pub fn free(self: *Allocator, memory: var) void { |
| 234 | const Slice = @typeInfo(@TypeOf(memory)).Pointer; | 234 | const Slice = @typeInfo(@TypeOf(memory)).Pointer; |
| 235 | const bytes = @sliceToBytes(memory); | 235 | const bytes = mem.sliceAsBytes(memory); |
| 236 | const bytes_len = bytes.len + if (Slice.sentinel != null) @sizeOf(Slice.child) else 0; | 236 | const bytes_len = bytes.len + if (Slice.sentinel != null) @sizeOf(Slice.child) else 0; |
| 237 | if (bytes_len == 0) return; | 237 | if (bytes_len == 0) return; |
| 238 | const non_const_ptr = @intToPtr([*]u8, @ptrToInt(bytes.ptr)); | 238 | const non_const_ptr = @intToPtr([*]u8, @ptrToInt(bytes.ptr)); |
lib/std/net.zig+2-2| ... | @@ -120,7 +120,7 @@ pub const Address = extern union { | ... | @@ -120,7 +120,7 @@ pub const Address = extern union { |
| 120 | ip_slice[10] = 0xff; | 120 | ip_slice[10] = 0xff; |
| 121 | ip_slice[11] = 0xff; | 121 | ip_slice[11] = 0xff; |
| 122 | 122 | ||
| 123 | const ptr = @sliceToBytes(@as(*const [1]u32, &addr)[0..]); | 123 | const ptr = mem.sliceAsBytes(@as(*const [1]u32, &addr)[0..]); |
| 124 | 124 | ||
| 125 | ip_slice[12] = ptr[0]; | 125 | ip_slice[12] = ptr[0]; |
| 126 | ip_slice[13] = ptr[1]; | 126 | ip_slice[13] = ptr[1]; |
| ... | @@ -164,7 +164,7 @@ pub const Address = extern union { | ... | @@ -164,7 +164,7 @@ pub const Address = extern union { |
| 164 | .addr = undefined, | 164 | .addr = undefined, |
| 165 | }, | 165 | }, |
| 166 | }; | 166 | }; |
| 167 | const out_ptr = @sliceToBytes(@as(*[1]u32, &result.in.addr)[0..]); | 167 | const out_ptr = mem.sliceAsBytes(@as(*[1]u32, &result.in.addr)[0..]); |
| 168 | 168 | ||
| 169 | var x: u8 = 0; | 169 | var x: u8 = 0; |
| 170 | var index: u8 = 0; | 170 | var index: u8 = 0; |
lib/std/os.zig+1-1| ... | @@ -1778,7 +1778,7 @@ pub fn isCygwinPty(handle: fd_t) bool { | ... | @@ -1778,7 +1778,7 @@ pub fn isCygwinPty(handle: fd_t) bool { |
| 1778 | 1778 | ||
| 1779 | const name_info = @ptrCast(*const windows.FILE_NAME_INFO, &name_info_bytes[0]); | 1779 | const name_info = @ptrCast(*const windows.FILE_NAME_INFO, &name_info_bytes[0]); |
| 1780 | const name_bytes = name_info_bytes[size .. size + @as(usize, name_info.FileNameLength)]; | 1780 | const name_bytes = name_info_bytes[size .. size + @as(usize, name_info.FileNameLength)]; |
| 1781 | const name_wide = @bytesToSlice(u16, name_bytes); | 1781 | const name_wide = mem.bytesAsSlice(u16, name_bytes); |
| 1782 | return mem.indexOf(u16, name_wide, &[_]u16{ 'm', 's', 'y', 's', '-' }) != null or | 1782 | return mem.indexOf(u16, name_wide, &[_]u16{ 'm', 's', 'y', 's', '-' }) != null or |
| 1783 | mem.indexOf(u16, name_wide, &[_]u16{ '-', 'p', 't', 'y' }) != null; | 1783 | mem.indexOf(u16, name_wide, &[_]u16{ '-', 'p', 't', 'y' }) != null; |
| 1784 | } | 1784 | } |
lib/std/process.zig+1-1| ... | @@ -436,7 +436,7 @@ pub fn argsAlloc(allocator: *mem.Allocator) ![][]u8 { | ... | @@ -436,7 +436,7 @@ pub fn argsAlloc(allocator: *mem.Allocator) ![][]u8 { |
| 436 | const buf = try allocator.alignedAlloc(u8, @alignOf([]u8), total_bytes); | 436 | const buf = try allocator.alignedAlloc(u8, @alignOf([]u8), total_bytes); |
| 437 | errdefer allocator.free(buf); | 437 | errdefer allocator.free(buf); |
| 438 | 438 | ||
| 439 | const result_slice_list = @bytesToSlice([]u8, buf[0..slice_list_bytes]); | 439 | const result_slice_list = mem.bytesAsSlice([]u8, buf[0..slice_list_bytes]); |
| 440 | const result_contents = buf[slice_list_bytes..]; | 440 | const result_contents = buf[slice_list_bytes..]; |
| 441 | mem.copy(u8, result_contents, contents_slice); | 441 | mem.copy(u8, result_contents, contents_slice); |
| 442 | 442 |
lib/std/unicode.zig+6-6| ... | @@ -243,7 +243,7 @@ pub const Utf16LeIterator = struct { | ... | @@ -243,7 +243,7 @@ pub const Utf16LeIterator = struct { |
| 243 | 243 | ||
| 244 | pub fn init(s: []const u16) Utf16LeIterator { | 244 | pub fn init(s: []const u16) Utf16LeIterator { |
| 245 | return Utf16LeIterator{ | 245 | return Utf16LeIterator{ |
| 246 | .bytes = @sliceToBytes(s), | 246 | .bytes = mem.sliceAsBytes(s), |
| 247 | .i = 0, | 247 | .i = 0, |
| 248 | }; | 248 | }; |
| 249 | } | 249 | } |
| ... | @@ -496,7 +496,7 @@ pub fn utf16leToUtf8(utf8: []u8, utf16le: []const u16) !usize { | ... | @@ -496,7 +496,7 @@ pub fn utf16leToUtf8(utf8: []u8, utf16le: []const u16) !usize { |
| 496 | 496 | ||
| 497 | test "utf16leToUtf8" { | 497 | test "utf16leToUtf8" { |
| 498 | var utf16le: [2]u16 = undefined; | 498 | var utf16le: [2]u16 = undefined; |
| 499 | const utf16le_as_bytes = @sliceToBytes(utf16le[0..]); | 499 | const utf16le_as_bytes = mem.sliceAsBytes(utf16le[0..]); |
| 500 | 500 | ||
| 501 | { | 501 | { |
| 502 | mem.writeIntSliceLittle(u16, utf16le_as_bytes[0..], 'A'); | 502 | mem.writeIntSliceLittle(u16, utf16le_as_bytes[0..], 'A'); |
| ... | @@ -606,12 +606,12 @@ test "utf8ToUtf16Le" { | ... | @@ -606,12 +606,12 @@ test "utf8ToUtf16Le" { |
| 606 | { | 606 | { |
| 607 | const length = try utf8ToUtf16Le(utf16le[0..], "𐐷"); | 607 | const length = try utf8ToUtf16Le(utf16le[0..], "𐐷"); |
| 608 | testing.expectEqual(@as(usize, 2), length); | 608 | testing.expectEqual(@as(usize, 2), length); |
| 609 | testing.expectEqualSlices(u8, "\x01\xd8\x37\xdc", @sliceToBytes(utf16le[0..])); | 609 | testing.expectEqualSlices(u8, "\x01\xd8\x37\xdc", mem.sliceAsBytes(utf16le[0..])); |
| 610 | } | 610 | } |
| 611 | { | 611 | { |
| 612 | const length = try utf8ToUtf16Le(utf16le[0..], "\u{10FFFF}"); | 612 | const length = try utf8ToUtf16Le(utf16le[0..], "\u{10FFFF}"); |
| 613 | testing.expectEqual(@as(usize, 2), length); | 613 | testing.expectEqual(@as(usize, 2), length); |
| 614 | testing.expectEqualSlices(u8, "\xff\xdb\xff\xdf", @sliceToBytes(utf16le[0..])); | 614 | testing.expectEqualSlices(u8, "\xff\xdb\xff\xdf", mem.sliceAsBytes(utf16le[0..])); |
| 615 | } | 615 | } |
| 616 | } | 616 | } |
| 617 | 617 | ||
| ... | @@ -619,13 +619,13 @@ test "utf8ToUtf16LeWithNull" { | ... | @@ -619,13 +619,13 @@ test "utf8ToUtf16LeWithNull" { |
| 619 | { | 619 | { |
| 620 | const utf16 = try utf8ToUtf16LeWithNull(testing.allocator, "𐐷"); | 620 | const utf16 = try utf8ToUtf16LeWithNull(testing.allocator, "𐐷"); |
| 621 | defer testing.allocator.free(utf16); | 621 | defer testing.allocator.free(utf16); |
| 622 | testing.expectEqualSlices(u8, "\x01\xd8\x37\xdc", @sliceToBytes(utf16[0..])); | 622 | testing.expectEqualSlices(u8, "\x01\xd8\x37\xdc", mem.sliceAsBytes(utf16[0..])); |
| 623 | testing.expect(utf16[2] == 0); | 623 | testing.expect(utf16[2] == 0); |
| 624 | } | 624 | } |
| 625 | { | 625 | { |
| 626 | const utf16 = try utf8ToUtf16LeWithNull(testing.allocator, "\u{10FFFF}"); | 626 | const utf16 = try utf8ToUtf16LeWithNull(testing.allocator, "\u{10FFFF}"); |
| 627 | defer testing.allocator.free(utf16); | 627 | defer testing.allocator.free(utf16); |
| 628 | testing.expectEqualSlices(u8, "\xff\xdb\xff\xdf", @sliceToBytes(utf16[0..])); | 628 | testing.expectEqualSlices(u8, "\xff\xdb\xff\xdf", mem.sliceAsBytes(utf16[0..])); |
| 629 | testing.expect(utf16[2] == 0); | 629 | testing.expect(utf16[2] == 0); |
| 630 | } | 630 | } |
| 631 | } | 631 | } |