]> git.lizzy.rs Git - rust.git/commit
Rollup merge of #68381 - mjp41:master, r=Dylan-DPC
authorYuki Okushi <huyuumi.dev@gmail.com>
Mon, 20 Jan 2020 22:32:48 +0000 (07:32 +0900)
committerGitHub <noreply@github.com>
Mon, 20 Jan 2020 22:32:48 +0000 (07:32 +0900)
commit32ecb6f1f2ad9a29c0d98bf9dd39a97467ce06e3
tree163b1b90cc71c136f348124ddf8a26c4b50b1663
parent67b87c8ba861af77bee44e3375619151fac045bc
parent6be3446f92b444cd6584c7948be9f7cf20ce5518
Rollup merge of #68381 - mjp41:master, r=Dylan-DPC

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.