Skip to content

Commit c406505

Browse files
committed
std.ArrayList: actaully memset to undefined in shrinkRetainingCapacity and clearRetainingCapacity
See ziglang#25810
1 parent 416bf1d commit c406505

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/std/array_list.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,15 +380,15 @@ pub fn AlignedManaged(comptime T: type, comptime alignment: ?mem.Alignment) type
380380
/// Asserts that the new length is less than or equal to the previous length.
381381
pub fn shrinkRetainingCapacity(self: *Self, new_len: usize) void {
382382
assert(new_len <= self.items.len);
383-
self.items.len = new_len;
384383
@memset(self.items[new_len..], undefined);
384+
self.items.len = new_len;
385385
}
386386

387387
/// Reduce length to 0.
388388
/// Invalidates all element pointers.
389389
pub fn clearRetainingCapacity(self: *Self) void {
390-
self.items.len = 0;
391390
@memset(self.items, undefined);
391+
self.items.len = 0;
392392
}
393393

394394
/// Invalidates all element pointers.

0 commit comments

Comments
 (0)