diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-04-13 21:44:40 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-04-25 11:23:40 -0700 |
| commit | a5c910adb610ae530db99f10aa77aaed3e85e830 (patch) | |
| tree | 5c3f72dbac50fc9f09608be3d7ea328c629c00a0 /lib/std/array_hash_map.zig | |
| parent | 8d88dcdc61c61e3410138f4402482131f5074a80 (diff) | |
| download | zig-a5c910adb610ae530db99f10aa77aaed3e85e830.tar.gz zig-a5c910adb610ae530db99f10aa77aaed3e85e830.zip | |
change semantics of `@memcpy` and `@memset`
Now they use slices or array pointers with any element type instead of
requiring byte pointers.
This is a breaking enhancement to the language.
The safety check for overlapping pointers will be implemented in a
future commit.
closes #14040
Diffstat (limited to 'lib/std/array_hash_map.zig')
| -rw-r--r-- | lib/std/array_hash_map.zig | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/std/array_hash_map.zig b/lib/std/array_hash_map.zig index 04b4e96cd5..bf43f24bc0 100644 --- a/lib/std/array_hash_map.zig +++ b/lib/std/array_hash_map.zig @@ -1893,7 +1893,7 @@ const IndexHeader = struct { const index_size = hash_map.capacityIndexSize(new_bit_index); const nbytes = @sizeOf(IndexHeader) + index_size * len; const bytes = try allocator.alignedAlloc(u8, @alignOf(IndexHeader), nbytes); - @memset(bytes.ptr + @sizeOf(IndexHeader), 0xff, bytes.len - @sizeOf(IndexHeader)); + @memset(bytes[@sizeOf(IndexHeader)..], 0xff); const result = @ptrCast(*IndexHeader, bytes.ptr); result.* = .{ .bit_index = new_bit_index, @@ -1914,7 +1914,7 @@ const IndexHeader = struct { const index_size = hash_map.capacityIndexSize(header.bit_index); const ptr = @ptrCast([*]align(@alignOf(IndexHeader)) u8, header); const nbytes = @sizeOf(IndexHeader) + header.length() * index_size; - @memset(ptr + @sizeOf(IndexHeader), 0xff, nbytes - @sizeOf(IndexHeader)); + @memset(ptr[@sizeOf(IndexHeader)..nbytes], 0xff); } // Verify that the header has sufficient alignment to produce aligned arrays. |
