Crate dummy_alloc

Source
Expand description

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.

Structs§

DummyAllocator
A dummy allocator.