Crates.io | kioku |
lib.rs | kioku |
version | 0.3.1 |
source | src |
created_at | 2019-12-25 21:26:41.255058 |
updated_at | 2021-05-11 15:42:37.700979 |
description | A memory arena |
homepage | |
repository | https://github.com/cessen/kioku |
max_upload_size | |
id | 192377 |
size | 41,645 |
A growable memory arena for Copy types.
This arena works by internally allocating memory in large-ish blocks of memory one-at-a-time, and doling out memory from the current block in linear order until its space runs out.
Additionally, it attempts to minimize wasted space through some heuristics, and has special handling for larger-than-block-size allocation requests.
Some contrived example usage:
let arena = Arena::new().with_block_size(1024);
let integer = arena.alloc(42);
let array1 = arena.copy_slice(&[1, 2, 3, 4, 5, 42]);
assert_eq!(*integer, array1[5]);
*integer = 16;
array1[1] = 16;
assert_eq!(*integer, array1[1]);
let character = arena.alloc('A');
let array2 = arena.alloc_array('A', 42);
assert_eq!(array2.len(), 42);
assert_eq!(*character, array2[20]);
*character = '学';
array2[30] = '学';
assert_eq!(*character, array2[30]);
Other features include:
Allocating with specific memory alignment.
Allocating strings.
Configurable growth strategies.
This project is licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Kioku by you will be licensed as above, without any additional terms or conditions.