-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
handle zero-size allocations correctly #11635
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if p.is_null() { | ||
// we need a non-allocating way to print an error here | ||
abort(); | ||
if size == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and the above malloc
should probably have comments explaining why they're explicitly checking for the 0-sized case.
The `malloc` family of functions may return a null pointer for a zero-size allocation, which should not be interpreted as an out-of-memory error. If the implementation does not return a null pointer, then handling this will result in memory savings for zero-size types. This also switches some code to `malloc_raw` in order to maintain a centralized point for handling out-of-memory in `rt::global_heap`. Closes #11634
bors
added a commit
that referenced
this pull request
Jan 19, 2014
The `malloc` family of functions may return a null pointer for a zero-size allocation, which should not be interpreted as an out-of-memory error. If the implementation does not return a null pointer, then handling this will result in memory savings for zero-size types. This also switches some code to `malloc_raw` in order to maintain a centralized point for handling out-of-memory in `rt::global_heap`. Closes #11634
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Jul 25, 2022
…eykril Generate enum variant assist So, this is kind of a weird PR! I'm a complete newcomer to the `rust-analyzer` codebase, and so I browsed the "good first issue" tag, and found rust-lang#11635. Then I found two separate folks had taken stabs at it, most recently `@maartenflippo` — and there had been a review 3 days ago, but no activity in a little while, and the PR needed to be rebased since the crates were renamed from `snake_case` to `kebab-case`. So to get acquainted with the codebase I typed this PR by hand, looking at the diff in rust-lang#11995, and I also added a doc-test (that passes). I haven't taken into account the comments `@Veykril` left in rust-lang#11995, but I don't want to steal any of `@maartenflippo's` thunder! Closing this PR is perfectly fine. Or Maarten could use it as a "restart point"? Or I could finish it up, whichever feels best to everyone. I think what remains to be done in this PR, at least, is: * [x] Only disable the "generate function" assist if the name is `PascalCase` * [x] Only enable the "generate variant" assistant if the name is `PascalCase` * [x] Simplify with `adt.source()` as mentioned here: rust-lang/rust-analyzer#11995 (comment) * [ ] Add more tests for edge cases? Are there cases where simply adding one more indent level than the enum's indent level is not good enough? Some nested trickery I'm not thinking of right now? Anyway. This PR can go in any direction. You can tell me "no, tackle your own issue!" And I'll go do that and still be happy I got to take a look at rust-analyzer some by doing this. Or you can tell me "okay, now _you_ finish it", and I guess I'll try and finish it :) Closes rust-lang#11635
flip1995
pushed a commit
to flip1995/rust
that referenced
this pull request
Oct 21, 2023
[`into_iter_without_iter`]: walk up deref impl chain to find `iter` methods Fixes rust-lang#11635 changelog: [`into_iter_without_iter`]: walk up deref impl chain to find `iter` methods
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
malloc
family of functions may return a null pointer for azero-size allocation, which should not be interpreted as an
out-of-memory error.
If the implementation does not return a null pointer, then handling
this will result in memory savings for zero-size types.
This also switches some code to
malloc_raw
in order to maintain acentralized point for handling out-of-memory in
rt::global_heap
.Closes #11634