diff options
| author | Felix S. Klock II <pnkfelix@pnkfx.org> | 2017-05-23 14:47:09 +0200 |
|---|---|---|
| committer | Felix S. Klock II <pnkfelix@pnkfx.org> | 2017-06-15 23:48:12 +0200 |
| commit | 066fafe2062b17fac343219e0067edbc14b774ae (patch) | |
| tree | 384cc9b918862ba5424dc5a4aa1ac5e1bd5a0437 /src/rustllvm/RustWrapper.cpp | |
| parent | 258ae6dd9b1a8ac97986852fc9f00f7687004ccb (diff) | |
| download | rust-066fafe2062b17fac343219e0067edbc14b774ae.tar.gz rust-066fafe2062b17fac343219e0067edbc14b774ae.zip | |
Add API for `Alloc` trait.
Includes `alloc_zeroed` method that `RawVec` has come to depend on. Exposed private `Layout::from_size_align` ctor to be `pub`, and added explicit conditions for when it will panic (namely, when `align` is not power-of-two, or if rounding up `size` to a multiple of `align` overflows). Normalized all `Layout` construction to go through `Layout::from_size_align`. Addressed review feedback regarding `struct Layout` and zero-sized layouts. Restrict specification for `dealloc`, adding additional constraint that the given alignment has to match that used to allocate the block. (This is a maximally conservative constraint on the alignment. An open question to resolve (before stabilization) is whether we can return to a looser constraint such as the one previously specified.) Split `fn realloc_in_place` into separate `fn grow_in_place` and `fn shrink_in_place` methods, which have default impls that check against usable_size for reuse. Make `realloc` default impl try `grow_in_place` or `shrink_in_place` as appropriate before fallback on alloc+copy+dealloc. Drive-by: When reviewing calls to `padding_needed_for`, discovered what I think was an over-conservative choice for its argument alignment. Namely, in `fn extend`, we automatically realign the whole resulting layout to satisfy both old (self) and new alignments. When the old alignment exceeds the new, this means we would insert unnecessary padding. So I changed the code to pass in `next.align` instead of `new_align` to `padding_needed_for`. Replaced ref to `realloc_in_place` with `grow_in_place`/`shrink_in_place`. Revised docs replacing my idiosyncratic style of `fn foo` with just `foo` when referring to the function or method `foo`. (Alpha-renamed `Allocator` to `Alloc`.) Post-rebased, added `Debug` derive for `allocator::Excess` to satisfy `missing_debug_implementations`.
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions
