Added minor clarification to specification of GlobalAlloc::realloc.#68381
Merged
bors merged 1 commit intorust-lang:masterfrom Jan 21, 2020
Merged
Added minor clarification to specification of GlobalAlloc::realloc.#68381bors merged 1 commit intorust-lang:masterfrom
bors merged 1 commit intorust-lang:masterfrom
Conversation
The `layout` for the returned allocation of a `realloc` is only implicitly specified. This change makes it explicit.
Contributor
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @cramertj (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
|
@bors r+ rollup |
Collaborator
|
📌 Commit 6be3446 has been approved by |
Dylan-DPC-zz
pushed a commit
to Dylan-DPC-zz/rust
that referenced
this pull request
Jan 20, 2020
Added minor clarification to specification of GlobalAlloc::realloc.
The specification of `realloc` is slightly unclear:
```
/// * `layout` must be the same layout that was used
/// to allocate that block of memory,
```
https://github.com/rust-lang/rust/blob/master/src/libcore/alloc.rs#L541-L542
In the case of an `alloc` or `alloc_zeroed` this is fairly evidently the `layout` parameter passed into the original call. In the case of a `realloc`, this I assume is `layout` modified to contain `new_size`. However, I could not find this case specified in the documentation. Thus technically in a sequence of calls to `realloc`, it would be valid to provide the second call to `realloc` the same `layout` as the first call to `realloc`, which is almost certainly not going to be handled correctly.
This PR attempts to clarify the specification.
JohnTitor
added a commit
to JohnTitor/rust
that referenced
this pull request
Jan 20, 2020
Added minor clarification to specification of GlobalAlloc::realloc.
The specification of `realloc` is slightly unclear:
```
/// * `layout` must be the same layout that was used
/// to allocate that block of memory,
```
https://github.com/rust-lang/rust/blob/master/src/libcore/alloc.rs#L541-L542
In the case of an `alloc` or `alloc_zeroed` this is fairly evidently the `layout` parameter passed into the original call. In the case of a `realloc`, this I assume is `layout` modified to contain `new_size`. However, I could not find this case specified in the documentation. Thus technically in a sequence of calls to `realloc`, it would be valid to provide the second call to `realloc` the same `layout` as the first call to `realloc`, which is almost certainly not going to be handled correctly.
This PR attempts to clarify the specification.
bors
added a commit
that referenced
this pull request
Jan 20, 2020
Rollup of 8 pull requests Successful merges: - #67734 (Remove appendix from Apache license) - #67795 (Cleanup formatting code) - #68290 (Fix some tests failing in `--pass check` mode) - #68297 ( Filter and test predicates using `normalize_and_test_predicates` for const-prop) - #68302 (Fix #[track_caller] and function pointers) - #68339 (Add `riscv64gc-unknown-linux-gnu` into target list in build-manifest) - #68381 (Added minor clarification to specification of GlobalAlloc::realloc.) - #68397 (rustdoc: Correct order of `async` and `unsafe` in `async unsafe fn`s) Failed merges: r? @ghost
This file contains hidden or 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
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 specification of
reallocis slightly unclear:https://github.com/rust-lang/rust/blob/master/src/libcore/alloc.rs#L541-L542
In the case of an
allocoralloc_zeroedthis is fairly evidently thelayoutparameter passed into the original call. In the case of arealloc, this I assume islayoutmodified to containnew_size. However, I could not find this case specified in the documentation. Thus technically in a sequence of calls torealloc, it would be valid to provide the second call toreallocthe samelayoutas the first call torealloc, which is almost certainly not going to be handled correctly.This PR attempts to clarify the specification.