about summary refs log tree commit diff
path: root/library/std/src/alloc.rs
AgeCommit message (Collapse)AuthorLines
2025-07-03Make __rust_alloc_error_handler_should_panic a functionDaniel Paoliello-2/+2
2025-04-27use generic Atomic type where possibleChristopher Durham-2/+2
in core/alloc/std only for now, and ignoring test files Co-authored-by: Pavel Grigorenko <GrigorenkoPV@ya.ru>
2025-04-09update cfgsBoxy-1/+1
2025-03-17Mark imports of #[rustc_std_internal_symbol] items with this attributebjorn3-0/+1
This ensures that they will be correctly mangled in a future commit.
2025-02-14std: Apply unsafe_op_in_unsafe_fnEric Huss-4/+4
2025-02-09Mark extern blocks as unsafeMichael Goulet-1/+1
2024-07-29Reformat `use` declarations.Nicholas Nethercote-2/+1
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-06-11Unify guarantees about the default allocatorTobias Bucher-1/+3
`std::alloc` said that the default allocator is unspecified for all crrate types except `cdylib` and `staticlib`. Adjust `std::alloc::System` documentation to say the same. Fixes #125870.
2024-05-03default_alloc_error_hook: explain difference to default __rdl_oom in allocRalf Jung-0/+6
2024-03-19SeqCst->{Release,Acquire} for alloc error hook.Mara Bos-3/+3
SeqCst is unnecessary.
2024-01-13libs: use `assert_unchecked` instead of intrinsicjoboet-3/+3
2023-08-19Correct and expand documentation of `handle_alloc_error` and ↵Kevin Reid-6/+20
`set_alloc_error_hook`. Add the following facts: * `handle_alloc_error` may panic instead of aborting. * What happens if a hook returns rather than diverging. * A hook may panic. (This was already demonstrated in an example, but not stated in prose.) * A hook must be sound to call — it cannot assume that it is only called by the runtime, since its function pointer can be retrieved by safe code.
2023-07-24remove additional [allow(unused_unsafe)]James Dietz-1/+0
2023-01-08Change memory ordering in System wrapper exampleMikail Bagishov-4/+4
Currently, the `SeqCst` ordering is used, which seems unnecessary: + Even `Relaxed` ordering guarantees that all updates are atomic and are executed in total order + User code only reads atomic for monitoring purposes, no "happens-before" relationships with actual allocations and deallocations are needed for this If argumentation above is correct, I propose changing ordering to `Relaxed` to clarify that no synchronization is required here, and improve performance (if somebody copy-pastes this example into their code).
2023-01-02default OOM handler: use non-unwinding panic (unless -Zoom=panic is set), to ↵Ralf Jung-1/+1
match std handler
2022-09-03Forbid mixing `System` with sytem allocator callsChristopher Durham-1/+4
2022-06-26Update `std::alloc::System` docsLukas Wirth-1/+1
2022-06-18make std not use &A: Allocator instanceRalf Jung-4/+4
2022-06-07Add std::alloc::set_alloc_error_hook exampleLucas Dumont-0/+14
2022-05-04update `jemallocator` example to use 2018 edition import syntaxkraktus-2/+0
2022-04-05trivial cfg(bootstrap) changesPietro Albini-3/+0
2022-03-18Auto merge of #88098 - Amanieu:oom_panic, r=nagisabors-1/+15
Implement -Z oom=panic This PR removes the `#[rustc_allocator_nounwind]` attribute on `alloc_error_handler` which allows it to unwind with a panic instead of always aborting. This is then used to implement `-Z oom=panic` as per RFC 2116 (tracking issue #43596). Perf and binary size tests show negligible impact.
2022-03-10Use implicit capture syntax in format_argsT-O-R-U-S-1/+1
This updates the standard library's documentation to use the new syntax. The documentation is worthwhile to update as it should be more idiomatic (particularly for features like this, which are nice for users to get acquainted with). The general codebase is likely more hassle than benefit to update: it'll hurt git blame, and generally updates can be done by folks updating the code if (and when) that makes things more readable with the new format. A few places in the compiler and library code are updated (mostly just due to already having been done when this commit was first authored).
2022-03-03Add -Z oom={panic,abort} command-line optionAmanieu d'Antras-1/+15
2021-05-19Rename `rterr` to `rtprintpanic`Christiaan Dirkx-1/+1
2021-05-19Replace `sys_common::util::dumb_print` with `rterr!`Christiaan Dirkx-3/+1
2021-01-07Fix safety commentLingMan-2/+3
The size assertion in the comment was inverted compared to the code. After fixing that the implication that `(new_size >= old_size) => new_size != 0` still doesn't hold so explain why `old_size != 0` at this point.
2020-12-17Add missing punctuation to std::alloc docspierwill-1/+1
Add a period to first line of module docs to match other modules in std.
2020-12-04 Rename `AllocRef` to `Allocator` and `(de)alloc` to `(de)allocate`Tim Diekmann-10/+10
2020-11-10Add missing newline to error message of the default OOM hookhyd-dev-1/+1
2020-09-28Rename AllocErr to AllocErrorJacob Hughes-10/+10
2020-09-22a few more &mut self -> self changesblitzerr-8/+8
2020-09-22removing &mut self for other methods of AllocRefblitzerr-2/+2
2020-09-21Changing the alloc() to accept &self instead of &mut selfblitzerr-2/+2
2020-09-08Capitalize safety commentsFlying-Toast-1/+1
2020-08-19Allow reallocation to different alignmentTim Diekmann-32/+53
2020-08-18Make `grow_impl` unsafeTim Diekmann-3/+6
2020-08-18Add comment, which was removed by accident (again)Tim Diekmann-0/+2
2020-08-18Clean up AllocRef implementation and documentationTim Diekmann-77/+77
2020-08-18Auto merge of #75621 - TimDiekmann:no-fast-realloc, r=Amanieubors-17/+10
Remove fast path in reallocation for same layout sizes r? @Amanieu Before merging a perf-run should be done. Closes https://github.com/rust-lang/wg-allocators/issues/70
2020-08-17Switch to intra-doc links for std/src/alloc.rsEllen-9/+0
2020-08-17Fix typo in commentTim Diekmann-2/+2
2020-08-17Remove fast path in reallocation for same layout sizesTim Diekmann-17/+10
2020-08-04Replace `Memoryblock` with `NonNull<[u8]>`Tim Diekmann-12/+16
2020-07-29Simplify implementations of `AllocRef` for `Global` and `System`Tim Diekmann-124/+73
2020-07-28Remove in-place allocation and revert to separate methods for zeroed allocationsTim Diekmann-66/+115
Fix docs
2020-07-27mv std libs to library/mark-0/+379