4 releases

0.2.0 May 21, 2024
0.1.2 May 16, 2024
0.1.1 May 10, 2024
0.1.0 May 10, 2024

#812 in Memory management

Download history 454/week @ 2025-10-15 529/week @ 2025-10-22 456/week @ 2025-10-29 328/week @ 2025-11-05 504/week @ 2025-11-12 372/week @ 2025-11-19 547/week @ 2025-11-26 470/week @ 2025-12-03 601/week @ 2025-12-10 147/week @ 2025-12-17 38/week @ 2025-12-24 46/week @ 2025-12-31 313/week @ 2026-01-07 371/week @ 2026-01-14 499/week @ 2026-01-21 317/week @ 2026-01-28

1,524 downloads per month

MIT/Apache

19KB
389 lines

A statically sized arena for byte buffers.

This crate provides an Arena for allocation of dynmically sized byte buffers ([u8]) without dependency on std or alloc.

Usage

use byte_arena::Arena;

// Create a new arena with 8KiB backing storage.
let mut arena = Arena::new([0; 8192]);

// Allocate a 1KiB buffer.
let mut buf = arena.alloc(1024).unwrap();
buf.fill(42);
// The index allows access to the allocation after the
// buffer has been dropped.
let mut buf_index = buf.index();

// Allocate a 1KiB zeroed buffer.
let mut zeroed_buf = arena.alloc(1024).unwrap();
let mut zeroed_buf_index = zeroed_buf.index();

let buf = arena.get(buf_index).unwrap();

arena.dealloc(buf_index);
arena.dealloc(zeroed_buf_index);

Note that the use of Index values between different Arena instances is not specified and may cause panics, corrupt the internal representations but will not cause undefined behavior.


byte-arena

no_std, no_alloc arena for allocating byte buffers.

Usage

Add byte-arena to your Cargo.toml:

byte-arena = "0.1.0"

Refer to docs.rs for the usage of this crate.

License

Licensed under either

No runtime deps

Features