2 releases (1 stable)

new 1.0.0 Jul 5, 2025
0.1.0 Jan 23, 2024

#591 in Memory management

Download history 1/week @ 2025-03-08 8/week @ 2025-03-15 6/week @ 2025-05-03 14/week @ 2025-05-10 1/week @ 2025-05-17

88 downloads per month

BlueOak-1.0.0

4KB

dummy-alloc

Provides DummyAllocator, a global allocator that fails all allocations.


lib.rs:

Provides DummyAllocator, a global allocator that fails all allocations.

Example

use std::alloc::{alloc, Layout};
use dummy_alloc::DummyAllocator;

// Configure it as the global allocator.
#[global_allocator]
static GLOBAL: DummyAllocator = DummyAllocator;

let layout = Layout::new::<i32>();
let ptr = unsafe { alloc(layout) };
// `DummyAllocator` always returns a null pointer on allocation.
assert!(ptr.is_null());

Similar crates

lol_alloc exports a similar FailAllocator that performs the same function.

Minimum supported Rust version

The MSRV is currently 1.56.

This may change between minor versions.

License

This crate is licensed under the Blue Oak Model License 1.0.0.

No runtime deps