about summary refs log tree commit diff
path: root/src/libcore/alloc.rs
AgeCommit message (Collapse)AuthorLines
2019-07-18Fix clippy::clone_on_copy warningsMateusz Mikuła-2/+2
2019-07-09Add missing links for CannotReallocInPlace typeGuillaume Gomez-2/+5
2019-05-19Rollup merge of #60947 - blkerby:global_alloc_typo, r=jonas-schievinkMazdak Farrokhzad-2/+2
Fix typos in docs of GlobalAlloc
2019-05-18Fix typos in docs of GlobalAllocBrent Kerby-2/+2
2019-05-14Mark core::alloc::Layout::from_size_align_unchecked constRichard Wiedenhöft-1/+1
2019-04-19libcore: deny more...Mazdak Farrokhzad-3/+3
2019-04-18libcore => 2018Taiki Endo-6/+6
2019-02-25heading # Unsafety => # Safety in stdlib docs.Mazdak Farrokhzad-2/+2
2019-02-10tests: doc commentsAlexander Regueiro-1/+1
2018-12-25Remove licensesMark Rousskov-10/+0
2018-12-07Various minor/cosmetic improvements to codeAlexander Regueiro-12/+12
2018-11-11Rollup merge of #55844 - waywardmonkeys:typo-fixes, r=varkorPietro Albini-2/+2
Fix documentation typos.
2018-11-10Fix documentation typos.Bruce Mitchener-2/+2
2018-11-08Fix Rc/Arc allocation layoutMurarth-0/+17
* Rounds allocation layout up to a multiple of alignment * Adds a convenience method `Layout::pad_to_align` to perform rounding
2018-11-06Add a tracking issue for extra Layout methodsAmanieu d'Antras-7/+7
2018-11-06API changes as discussed in the commentsAmanieu d'Antras-17/+6
2018-11-06Add a comment about how Layout::extend matches the C struct layoutAmanieu d'Antras-0/+3
2018-10-23fix typos in various placesMatthias Krüger-1/+1
2018-08-04Remove explicit returns where unnecessaryljedrz-5/+5
2018-08-01Switch to bootstrapping from 1.29 betaMark Rousskov-5/+1
2018-07-09Implement #[alloc_error_handler]Simon Sapin-0/+1
This to-be-stable attribute is equivalent to `#[lang = "oom"]`. It is required when using the alloc crate without the std crate. It is called by `handle_alloc_error`, which is in turned called by "infallible" allocations APIs such as `Vec::push`.
2018-06-29Move core::alloc::CollectionAllocErr to alloc::collectionsSimon Sapin-28/+0
2018-06-27Document that Layout::from_size_align does not allow align=0Simon Sapin-0/+2
This was already implied since zero is not a power of two, but maybe worth pointing out.
2018-06-18Rename OOM to allocation errorSimon Sapin-24/+24
The acronym is not descriptive unless one has seen it before. * Rename the `oom` function to `handle_alloc_error`. It was **stabilized in 1.28**, so if we do this at all we need to land it this cycle. * Rename `set_oom_hook` to `set_alloc_error_hook` * Rename `take_oom_hook` to `take_alloc_error_hook` Bikeshed: `alloc` v.s. `allocator`, `error` v.s. `failure`
2018-06-11More alloc docs tweaksSimon Sapin-1/+23
2018-06-11Alloc docs teaksSimon Sapin-5/+0
2018-06-11Stablize the GlobalAlloc traitSimon Sapin-1/+5
Fixes https://github.com/rust-lang/rust/issues/49668
2018-06-11Stabilize alloc::Layout (with only some of its methods)Simon Sapin-9/+9
2018-06-11Mark as permanently-unstable some implementation detailsSimon Sapin-1/+1
2018-06-11Stablize the alloc module without changing stability of its contents.Simon Sapin-6/+26
2018-06-11Document memory allocation APIsSimon Sapin-49/+178
Add some docs where they were missing, attempt to fix them where they were out of date.
2018-06-11Remove alloc::Opaque and use *mut u8 as pointer type for GlobalAllocMike Hommey-41/+24
2018-06-02Rollup merge of #51226 - gnzlbg:nonzero_align, r=SimonSapinMark Simulacrum-37/+43
Make Layout's align a NonZeroUsize This PR makes the `Layout`'s align field a `NonZeroUsize` since it cannot ever be zero, not even while building a `Layout`. It also contains some drive-by minor cleanups over the docs and the code, like updating the documented error types, or using the `size()` and `align()` methods instead of accessing the fields directly (the latter was required for the `NonZeroUsize` change anyways). r? @SimonSapin cc @Amanieu
2018-06-02add missing inline's and optimizationsgnzlbg-4/+11
2018-06-02remove debug_assert in padding_needed_forgnzlbg-3/+0
2018-06-01Simplify HashMap layout calculation by using LayoutAmanieu d'Antras-0/+8
2018-05-30make Layout's align a NonZeroUsizegnzlbg-36/+38
2018-04-22Remove Alloc::oomSteven Fackler-26/+0
2018-04-22Replace GlobalAlloc::oom with a lang itemSteven Fackler-11/+0
2018-04-20Implement Copy for std::alloc::LayoutSimon Sapin-1/+1
Fixes https://github.com/rust-lang/rust/issues/48458
2018-04-15Auto merge of #49884 - alexcrichton:less-unwrap, r=Mark-Simulacrumbors-8/+14
core: Remove panics from some `Layout` methods `Layout` is often used at the core of allocation APIs and is as a result pretty sensitive to codegen in various circumstances. I was profiling `-C opt-level=z` with a wasm project recently and noticed that the `unwrap()` wasn't removed inside of `Layout`, causing the program to be much larger than it otherwise would be. If inlining were more aggressive LLVM would have figured out that the panic could be eliminated, but in general the methods here can't panic in the first place! As a result this commit makes the following tweaks: * Removes `unwrap()` and replaces it with `unsafe` in `Layout::new` and `Layout::for_value`. For posterity though a debug assertion was left behind. * Removes an `unwrap()` in favor of `?` in the `repeat` method. The comment indicating that the function call couldn't panic wasn't quite right in that if `alloc_size` becomes too large and if `align` is high enough it could indeed cause a panic. This'll hopefully mean that panics never get introduced into code in the first place, ensuring that `opt-level=z` is closer to `opt-level=s` in this regard.
2018-04-13core: Remove panics from some `Layout` methodsAlex Crichton-8/+14
`Layout` is often used at the core of allocation APIs and is as a result pretty sensitive to codegen in various circumstances. I was profiling `-C opt-level=z` with a wasm project recently and noticed that the `unwrap()` wasn't removed inside of `Layout`, causing the program to be much larger than it otherwise would be. If inlining were more aggressive LLVM would have figured out that the panic could be eliminated, but in general the methods here can't panic in the first place! As a result this commit makes the following tweaks: * Removes `unwrap()` and replaces it with `unsafe` in `Layout::new` and `Layout::for_value`. For posterity though a debug assertion was left behind. * Removes an `unwrap()` in favor of `?` in the `repeat` method. The comment indicating that the function call couldn't panic wasn't quite right in that if `alloc_size` becomes too large and if `align` is high enough it could indeed cause a panic. This'll hopefully mean that panics never get introduced into code in the first place, ensuring that `opt-level=z` is closer to `opt-level=s` in this regard.
2018-04-13core: Inline `From<AllocErr> for CollectionAllocErr`Alex Crichton-0/+1
This shows up in allocations of vectors and such, so no need for it to not be inlined!
2018-04-12Initial docs for the GlobalAlloc traitSimon Sapin-5/+39
2018-04-12Rename alloc::Void to alloc::OpaqueSimon Sapin-19/+19
2018-04-12Remove conversions for allocated pointersSimon Sapin-17/+0
One was now unused, and `NonNull::new(…).ok_or(AllocErr)` feels short enough for the few cases that need the other conversion.
2018-04-12Use NonNull<Void> instead of *mut u8 in the Alloc traitMike Hommey-33/+25
Fixes #49608
2018-04-12Restore Global.oom() functionalitySimon Sapin-0/+4
… now that #[global_allocator] does not define a symbol for it
2018-04-12Conversions between Result<*mut u8, AllocErr>> and *mut VoidSimon Sapin-0/+21
2018-04-12realloc with a new size only, not a full new layout.Simon Sapin-51/+36
Changing the alignment with realloc is not supported.