2 releases
0.1.2 | Oct 22, 2022 |
---|---|
0.1.1 |
|
0.1.0 | Oct 19, 2022 |
#131 in #memory-allocator
67 downloads per month
Used in 2 crates
(via golana-loader)
15KB
340 lines
smalloc
A small memory allocator for Solana programs
lib.rs
:
Smalloc is a small and simple memory allocator for Solana programs.
Usage:
-
Add this crate as dependency
-
Add a dummy feature called "custom-heap" in Cargo.toml:
[features]
default = ["custom-heap"]
custom-heap = []
- Put this in your entrypoint.rs
// START: Heap start
// LENGTH: Heap length
// MIN: Minimal allocation size
// PAGE_SIZE: Allocation page size
#[cfg(target_os = "solana")]
#[global_allocator]
static ALLOC: Smalloc<{ HEAP_START_ADDRESS as usize }, { HEAP_LENGTH as usize }, 16, 1024> =
Smalloc::new();
Note: The "dynamic_start" feature is for unit tests.