Skip to content

Conversation

@mateusz834
Copy link
Contributor

Fixes #25796

@squeek502
Copy link
Member

Thanks!

@squeek502 squeek502 merged commit 416bf1d into ziglang:master Nov 6, 2025
16 of 18 checks passed
Comment on lines 381 to +391
pub fn shrinkRetainingCapacity(self: *Self, new_len: usize) void {
assert(new_len <= self.items.len);
self.items.len = new_len;
@memset(self.items[new_len..], undefined);
}

/// Reduce length to 0.
/// Invalidates all element pointers.
pub fn clearRetainingCapacity(self: *Self) void {
self.items.len = 0;
@memset(self.items, undefined);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... statements are switched around -- you're memsetting 0-len slices

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

std.ArrayList: shrinkRetainingCapacity and clearRetainingCapacity should memset to undefined

3 participants