| 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 | 24 | const Self = @This(); |
| 25 | 25 | |
| 26 | 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 | 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 | 34 | pub fn permute(self: *Self) void { |
lib/std/cstr.zig+1-1| ... | ... | @@ -72,7 +72,7 @@ pub const NullTerminated2DArray = struct { |
| 72 | 72 | errdefer allocator.free(buf); |
| 73 | 73 | |
| 74 | 74 | var write_index = index_size; |
| 75 | const index_buf = @bytesToSlice(?[*]u8, buf); | |
| 75 | const index_buf = mem.bytesAsSlice(?[*]u8, buf); | |
| 76 | 76 | |
| 77 | 77 | var i: usize = 0; |
| 78 | 78 | for (slices) |slice| { |
lib/std/fifo.zig+4-4| ... | ... | @@ -101,7 +101,7 @@ pub fn LinearFifo( |
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | 103 | { // set unused area to undefined |
| 104 | const unused = @sliceToBytes(self.buf[self.count..]); | |
| 104 | const unused = mem.sliceAsBytes(self.buf[self.count..]); | |
| 105 | 105 | @memset(unused.ptr, undefined, unused.len); |
| 106 | 106 | } |
| 107 | 107 | } |
| ... | ... | @@ -166,12 +166,12 @@ pub fn LinearFifo( |
| 166 | 166 | { // set old range to undefined. Note: may be wrapped around |
| 167 | 167 | const slice = self.readableSliceMut(0); |
| 168 | 168 | if (slice.len >= count) { |
| 169 | const unused = @sliceToBytes(slice[0..count]); | |
| 169 | const unused = mem.sliceAsBytes(slice[0..count]); | |
| 170 | 170 | @memset(unused.ptr, undefined, unused.len); |
| 171 | 171 | } else { |
| 172 | const unused = @sliceToBytes(slice[0..]); | |
| 172 | const unused = mem.sliceAsBytes(slice[0..]); | |
| 173 | 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 | 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 | 26 | } |
| 27 | 27 | |
| 28 | 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 | 32 | const WatchEventError = error{ |
lib/std/heap.zig+3-3| ... | ... | @@ -283,14 +283,14 @@ const WasmPageAllocator = struct { |
| 283 | 283 | |
| 284 | 284 | fn getBit(self: FreeBlock, idx: usize) PageStatus { |
| 285 | 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 | 289 | fn setBits(self: FreeBlock, start_idx: usize, len: usize, val: PageStatus) void { |
| 290 | 290 | const bit_offset = 0; |
| 291 | 291 | var i: usize = 0; |
| 292 | 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 | 552 | if (len >= actual_min_size) break; |
| 553 | 553 | } |
| 554 | 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 | 556 | const buf_node = &buf_node_slice[0]; |
| 557 | 557 | buf_node.* = BufNode{ |
| 558 | 558 | .data = buf, |
lib/std/io/in_stream.zig+1-1| ... | ... | @@ -235,7 +235,7 @@ pub fn InStream(comptime ReadError: type) type { |
| 235 | 235 | // Only extern and packed structs have defined in-memory layout. |
| 236 | 236 | comptime assert(@typeInfo(T).Struct.layout != builtin.TypeInfo.ContainerLayout.Auto); |
| 237 | 237 | var res: [1]T = undefined; |
| 238 | try self.readNoEof(@sliceToBytes(res[0..])); | |
| 238 | try self.readNoEof(mem.sliceAsBytes(res[0..])); | |
| 239 | 239 | return res[0]; |
| 240 | 240 | } |
| 241 | 241 |
lib/std/mem.zig+6-6| ... | ... | @@ -132,7 +132,7 @@ pub const Allocator = struct { |
| 132 | 132 | // their own frame with @Frame(func). |
| 133 | 133 | return @intToPtr([*]T, @ptrToInt(byte_slice.ptr))[0..n]; |
| 134 | 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 | 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 | 177 | const byte_count = math.mul(usize, @sizeOf(T), new_n) catch return Error.OutOfMemory; |
| 178 | 178 | // Note: can't set shrunk memory to undefined as memory shouldn't be modified on realloc failure |
| 179 | 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 | 181 | if (new_n > old_mem.len) { |
| 182 | 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 | 187 | /// Prefer calling realloc to shrink if you can tolerate failure, such as |
| ... | ... | @@ -221,18 +221,18 @@ pub const Allocator = struct { |
| 221 | 221 | // new_n <= old_mem.len and the multiplication didn't overflow for that operation. |
| 222 | 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 | 225 | @memset(old_byte_slice.ptr + byte_count, undefined, old_byte_slice.len - byte_count); |
| 226 | 226 | const byte_slice = self.shrinkFn(self, old_byte_slice, Slice.alignment, byte_count, new_alignment); |
| 227 | 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 | 231 | /// Free an array allocated with `alloc`. To free a single item, |
| 232 | 232 | /// see `destroy`. |
| 233 | 233 | pub fn free(self: *Allocator, memory: var) void { |
| 234 | 234 | const Slice = @typeInfo(@TypeOf(memory)).Pointer; |
| 235 | const bytes = @sliceToBytes(memory); | |
| 235 | const bytes = mem.sliceAsBytes(memory); | |
| 236 | 236 | const bytes_len = bytes.len + if (Slice.sentinel != null) @sizeOf(Slice.child) else 0; |
| 237 | 237 | if (bytes_len == 0) return; |
| 238 | 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 | 120 | ip_slice[10] = 0xff; |
| 121 | 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 | 125 | ip_slice[12] = ptr[0]; |
| 126 | 126 | ip_slice[13] = ptr[1]; |
| ... | ... | @@ -164,7 +164,7 @@ pub const Address = extern union { |
| 164 | 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 | 169 | var x: u8 = 0; |
| 170 | 170 | var index: u8 = 0; |
lib/std/os.zig+1-1| ... | ... | @@ -1778,7 +1778,7 @@ pub fn isCygwinPty(handle: fd_t) bool { |
| 1778 | 1778 | |
| 1779 | 1779 | const name_info = @ptrCast(*const windows.FILE_NAME_INFO, &name_info_bytes[0]); |
| 1780 | 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 | 1782 | return mem.indexOf(u16, name_wide, &[_]u16{ 'm', 's', 'y', 's', '-' }) != null or |
| 1783 | 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 | 436 | const buf = try allocator.alignedAlloc(u8, @alignOf([]u8), total_bytes); |
| 437 | 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 | 440 | const result_contents = buf[slice_list_bytes..]; |
| 441 | 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 | 243 | |
| 244 | 244 | pub fn init(s: []const u16) Utf16LeIterator { |
| 245 | 245 | return Utf16LeIterator{ |
| 246 | .bytes = @sliceToBytes(s), | |
| 246 | .bytes = mem.sliceAsBytes(s), | |
| 247 | 247 | .i = 0, |
| 248 | 248 | }; |
| 249 | 249 | } |
| ... | ... | @@ -496,7 +496,7 @@ pub fn utf16leToUtf8(utf8: []u8, utf16le: []const u16) !usize { |
| 496 | 496 | |
| 497 | 497 | test "utf16leToUtf8" { |
| 498 | 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 | 502 | mem.writeIntSliceLittle(u16, utf16le_as_bytes[0..], 'A'); |
| ... | ... | @@ -606,12 +606,12 @@ test "utf8ToUtf16Le" { |
| 606 | 606 | { |
| 607 | 607 | const length = try utf8ToUtf16Le(utf16le[0..], "𐐷"); |
| 608 | 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 | 612 | const length = try utf8ToUtf16Le(utf16le[0..], "\u{10FFFF}"); |
| 613 | 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 | 619 | { |
| 620 | 620 | const utf16 = try utf8ToUtf16LeWithNull(testing.allocator, "𐐷"); |
| 621 | 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 | 623 | testing.expect(utf16[2] == 0); |
| 624 | 624 | } |
| 625 | 625 | { |
| 626 | 626 | const utf16 = try utf8ToUtf16LeWithNull(testing.allocator, "\u{10FFFF}"); |
| 627 | 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 | 629 | testing.expect(utf16[2] == 0); |
| 630 | 630 | } |
| 631 | 631 | } |