Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don’t heap-allocate for zero-size items #228

Merged
merged 1 commit into from Jul 6, 2020
Merged

Don’t heap-allocate for zero-size items #228

merged 1 commit into from Jul 6, 2020

Conversation

SimonSapin
Copy link
Member

@SimonSapin SimonSapin commented Jul 6, 2020

Allocating zero bytes is Undefined Behavior.
CC servo/servo#26304 (comment)

Allocating zero bytes is Undefined Behavior.
CC servo/servo#26304 (comment)
core::usize::MAX
}
}

/// The maximum number of elements this vector can hold inline
#[inline]
pub fn inline_size(&self) -> usize {
Copy link
Member Author

@SimonSapin SimonSapin Jul 6, 2020

Choose a reason for hiding this comment

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

This should not take &self, but it’s public so meh

@jdm
Copy link
Member

jdm commented Jul 6, 2020

@bors-servo r+

@bors-servo
Copy link
Contributor

bors-servo commented Jul 6, 2020

📌 Commit a376b02 has been approved by jdm

@bors-servo
Copy link
Contributor

bors-servo commented Jul 6, 2020

Testing commit a376b02 with merge 5513f47...

@bors-servo
Copy link
Contributor

bors-servo commented Jul 6, 2020

☀️ Test successful - checks-travis
Approved by: jdm
Pushing 5513f47 to master...

@bors-servo bors-servo merged commit 5513f47 into master Jul 6, 2020
3 checks passed
@SimonSapin SimonSapin deleted the zero branch Jul 6, 2020
@SimonSapin
Copy link
Member Author

SimonSapin commented Jul 6, 2020

Published https://crates.io/crates/smallvec/1.4.1 and yanked https://crates.io/crates/smallvec/1.4.0 since it can trigger UB from safe code.

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.

None yet

3 participants