about summary refs log tree commit diff
path: root/src/liballoc/raw_vec.rs
AgeCommit message (Collapse)AuthorLines
2019-04-12Stabilize the `alloc` crate.Simon Sapin-2/+2
This implements RFC 2480: * https://github.com/rust-lang/rfcs/pull/2480 * https://github.com/rust-lang/rfcs/blob/master/text/2480-liballoc.md Closes https://github.com/rust-lang/rust/issues/27783
2019-02-10libs: doc commentsAlexander Regueiro-2/+2
2019-02-03liballoc: revert nested imports style changes.Mazdak Farrokhzad-13/+9
2019-02-02liballoc: apply uniform_paths.Mazdak Farrokhzad-2/+2
2019-02-02liballoc: adjust abolute imports + more import fixes.Mazdak Farrokhzad-1/+1
2019-02-02liballoc: refactor & fix some imports.Mazdak Farrokhzad-11/+14
2019-02-02liballoc: cargo check passes on 2018Mazdak Farrokhzad-5/+5
2019-01-08RawVec doesn't always abort on allocation errorsJonathan Behrens-1/+1
2018-12-25Remove licensesMark Rousskov-10/+0
2018-12-07Various minor/cosmetic improvements to codeAlexander Regueiro-1/+1
2018-11-13fix various typos in doc commentsAndy Russell-1/+1
2018-08-21Rollup merge of #53329 - frewsxcv:frewsxcv-ptr-add-sub, r=RalfJungkennytm-2/+2
Replace usages of ptr::offset with ptr::{add,sub}. Rust provides these helper methods – so let's use them!
2018-08-20Replace usages of ptr::offset with ptr::{add,sub}.Corey Farwell-2/+2
2018-08-19Fix typos found by codespell.Matthias Krüger-1/+1
2018-06-29Move core::alloc::CollectionAllocErr to alloc::collectionsSimon Sapin-2/+2
2018-06-29Make raw_vec perma-unstable and hiddenSimon Sapin-2/+5
2018-06-18Rename OOM to allocation errorSimon Sapin-6/+10
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-11Remove some unneeded castsSimon Sapin-3/+3
2018-06-11Remove alloc::Opaque and use *mut u8 as pointer type for GlobalAllocMike Hommey-10/+9
2018-05-30Pass a `Layout` to `oom`Mike Hommey-74/+82
As discussed in https://github.com/rust-lang/rust/issues/49668#issuecomment-384893456 and subsequent, there are use-cases where the OOM handler needs to know the size of the allocation that failed. The alignment might also be a cause for allocation failure, so providing it as well can be useful.
2018-05-10Restore RawVec::reserve* documentationMike Hommey-56/+57
When the RawVec::try_reserve* methods were added, they took the place of the ::reserve* methods in the source file, and new ::reserve* methods wrapping the new try_reserve* methods were created. But the documentation didn't move along, such that: - reserve_* methods are barely documented. - try_reserve_* methods have unmodified documentation from reserve_*, such that their documentation indicate they are panicking/aborting. This moves the documentation back to the right methods, with a placeholder documentation for the try_reserve* methods.
2018-05-08Cleanup a `use` in a raw_vec testMike Hommey-1/+1
`allocator` is deprecated in favor of `alloc`, and `Alloc` is already imported through `super::*`.
2018-04-29heh, logic is hardMark Mansi-1/+1
2018-04-29use const trickMark Mansi-23/+6
2018-04-25make RawVec::empty constMark Mansi-1/+4
2018-04-25Make Vec::new constMark Mansi-0/+16
2018-04-22Remove Alloc::oomSteven Fackler-7/+7
2018-04-16Auto merge of #49488 - alexcrichton:small-wasm-panic, r=sfacklerbors-8/+15
std: Minimize size of panicking on wasm This commit applies a few code size optimizations for the wasm target to the standard library, namely around panics. We notably know that in most configurations it's impossible for us to print anything in wasm32-unknown-unknown so we can skip larger portions of panicking that are otherwise simply informative. This allows us to get quite a nice size reduction. Finally we can also tweak where the allocation happens for the `Box<Any>` that we panic with. By only allocating once unwinding starts we can reduce the size of a panicking wasm module from 44k to 350 bytes.
2018-04-14Cleanup liballoc use statementsMike Hommey-4/+5
Some modules were still using the deprecated `allocator` module, use the `alloc` module instead. Some modules were using `super` while it's not needed. Some modules were more or less ordering them, and other not, so the latter have been modified to match the others.
2018-04-13Reduce the size of panics in RawVecAlex Crichton-8/+15
Create one canonical location which panics with "capacity overflow" instead of having many. This reduces the size of a `panic!("{}", 1)` binary on wasm from 34k to 17k.
2018-04-12Rename alloc::Void to alloc::OpaqueSimon Sapin-11/+11
2018-04-12Use NonNull<Void> instead of *mut u8 in the Alloc traitMike Hommey-21/+19
Fixes #49608
2018-04-12realloc with a new size only, not a full new layout.Simon Sapin-9/+8
Changing the alignment with realloc is not supported.
2018-04-12Return Result instead of Option in alloc::Layout constructorsSimon Sapin-2/+2
2018-04-12Remove the now-unit-struct AllocErr field inside CollectionAllocErrSimon Sapin-2/+2
2018-04-12Remove the now-unit-struct AllocErr parameter of oom()Simon Sapin-6/+6
2018-04-12Make AllocErr a zero-size unit structSimon Sapin-1/+1
2018-04-12Actually deprecate the Heap typeSimon Sapin-12/+11
2018-04-02Use Alloc and Layout from core::heap.Mike Hommey-1/+2
94d1970bba87f2d2893f6e934e4c3f02ed50604d moved the alloc::allocator module to core::heap, moving e.g. Alloc and Layout out of the alloc crate. While alloc::heap reexports them, it's better to use them from where they really come from.
2018-03-14implementing fallible allocation API (try_reserve) for Vec, String and HashMapsnf-42/+60
2018-01-20Replace Unique<T> with NonZero<T> in Alloc traitSimon Sapin-1/+1
2017-11-01Fix typo.Lance John-1/+1
2017-08-17Rollup merge of #43891 - Fourchaux:master, r=steveklabnikCorey Farwell-2/+2
Fix typos & us spellings Fixing some typos and non en-US spellings. (Update of PR https://github.com/rust-lang/rust/pull/42812 )
2017-08-15use field init shorthand EVERYWHEREZack M. Davis-7/+7
Like #43008 (f668999), but _much more aggressive_.
2017-08-15Fix typos & us spellingsFourchaux-2/+2
2017-08-12std: Unsafe-away runtime checks in `Vec`Alex Crichton-76/+127
The `RawVec` type has a number of invariants that it upholds throughout its execution, and as a result many of the runtime checks imposed by using `Layout` in a "raw" fashion aren't actually necessary. For example a `RawVec`'s capacity is intended to always match the layout which "fits" the allocation, so we don't need any runtime checks when retrieving the current `Layout` for a vector. Consequently, this adds a safe `current_layout` function which internally uses the `from_size_align_unchecked` function. Along the same lines we know that most construction of new layouts will not overflow. All allocations in `RawVec` are kept below `isize::MAX` and valid alignments are also kept low enough that we're guaranteed that `Layout` for a doubled vector will never overflow and will always succeed construction. Consequently a few locations can use `from_size_align_unchecked` in addition when constructing the *new* layout to allocate (or reallocate), which allows for eliding some more runtime checks. Overall this should significant improve performance for an important function, `RawVec::double`. This commit removes four runtime jumps before `__rust_realloc` is called, as well as one after it's called.
2017-07-22Rename {NonZero,Shared,Unique}::new to new_uncheckedSimon Sapin-3/+3
2017-07-05rustc: Implement the #[global_allocator] attributeAlex Crichton-11/+11
This PR is an implementation of [RFC 1974] which specifies a new method of defining a global allocator for a program. This obsoletes the old `#![allocator]` attribute and also removes support for it. [RFC 1974]: https://github.com/rust-lang/rfcs/pull/197 The new `#[global_allocator]` attribute solves many issues encountered with the `#![allocator]` attribute such as composition and restrictions on the crate graph itself. The compiler now has much more control over the ABI of the allocator and how it's implemented, allowing much more freedom in terms of how this feature is implemented. cc #27389
2017-06-23Removed as many "```ignore" as possible.kennytm-3/+19
Replaced by adding extra imports, adding hidden code (`# ...`), modifying examples to be runnable (sorry Homura), specifying non-Rust code, and converting to should_panic, no_run, or compile_fail. Remaining "```ignore"s received an explanation why they are being ignored.
2017-06-15Allocator integration in `RawVec`.Felix S. Klock II-117/+220
Includes methods exposing underlying allocator and the dellocation routine. Includes test illustrating a tiny `Alloc` that just bounds the total bytes allocated. Alpha-renamed `Allocator` to `Alloc` (and `HeapAllocator` to `HeapAlloc`).