Skip to main content

Crate range_alloc

Crate range_alloc 

Source
Expand description

A generic range allocator for managing sub-ranges within a larger range.

This crate provides RangeAllocator, which hands out non-overlapping Range<T> values from a pool. It uses a best-fit strategy to reduce fragmentation and automatically merges adjacent free ranges on deallocation.

§Example

use range_alloc::RangeAllocator;

let mut alloc = RangeAllocator::new(0..1024);

// Allocate two regions.
let a = alloc.allocate_range(256).unwrap(); // 0..256
let b = alloc.allocate_range(128).unwrap(); // 256..384

// Free the first region so it can be reused.
alloc.free_range(a);

§Minimum Supported Rust Version

The MSRV of this crate is at least 1.31, possibly earlier. It will only be bumped in a breaking release.

Structs§

RangeAllocationError
The error returned when an allocation cannot be satisfied.
RangeAllocator
A best-fit range allocator over a generic index type T.