Rollup merge of #95546 - autumnontape:allocator-realloc-align-docs, r=Amanieu
add notes about alignment-altering reallocations to Allocator docs As I said in https://github.com/rust-lang/wg-allocators/issues/97, the fact that calls to `grow`, `grow_zeroed`, and `shrink` may request altered alignments is surprising and may be a pitfall for implementors of `Allocator` if it's left implicit. This pull request adds a note to the "Safety" section of each function's docs making it explicit.
This commit is contained in:
commit
a92286f9c9
1 changed files with 6 additions and 0 deletions
|
|
@ -173,6 +173,8 @@ pub unsafe trait Allocator {
|
|||
/// * `old_layout` must [*fit*] that block of memory (The `new_layout` argument need not fit it.).
|
||||
/// * `new_layout.size()` must be greater than or equal to `old_layout.size()`.
|
||||
///
|
||||
/// Note that `new_layout.align()` need not be the same as `old_layout.align()`.
|
||||
///
|
||||
/// [*currently allocated*]: #currently-allocated-memory
|
||||
/// [*fit*]: #memory-fitting
|
||||
///
|
||||
|
|
@ -234,6 +236,8 @@ pub unsafe trait Allocator {
|
|||
/// * `old_layout` must [*fit*] that block of memory (The `new_layout` argument need not fit it.).
|
||||
/// * `new_layout.size()` must be greater than or equal to `old_layout.size()`.
|
||||
///
|
||||
/// Note that `new_layout.align()` need not be the same as `old_layout.align()`.
|
||||
///
|
||||
/// [*currently allocated*]: #currently-allocated-memory
|
||||
/// [*fit*]: #memory-fitting
|
||||
///
|
||||
|
|
@ -296,6 +300,8 @@ pub unsafe trait Allocator {
|
|||
/// * `old_layout` must [*fit*] that block of memory (The `new_layout` argument need not fit it.).
|
||||
/// * `new_layout.size()` must be smaller than or equal to `old_layout.size()`.
|
||||
///
|
||||
/// Note that `new_layout.align()` need not be the same as `old_layout.align()`.
|
||||
///
|
||||
/// [*currently allocated*]: #currently-allocated-memory
|
||||
/// [*fit*]: #memory-fitting
|
||||
///
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue