First of all, allocate 64KiB aligned memory regions for slab and buddy allocators.
```rust
use memac; use libc::{posixmemalign, cvoid};
static mut ALLOC: memac::Allocator
fn main() { println!("Hello, world!"); }
const HEAP_SIZE: usize = 32 * 1024 * 1024; // 32MiB
fn start(argc: isize, _argv: *const *const u8) -> isize { // initialize memory unsafe { // allocate memory let mut ptr: *mut cvoid = std::ptr::nullmut(); if posixmemalign(&mut ptr, memac::ALIGNMENT, HEAPSIZE) != 0 { panic!("posixmemalign"); } ALLOC.init(ptr as usize, HEAP_SIZE); }
main();
0
} ```
toml
[dependencies]
libc = "0.2"
memac = "0.5"
memac::Allocator<memac::budyy::Buddy32M>
means that
the slab allocator uses the buddy allocator to allocate slabs.
If a requested size is greater than (65512 - 8) bytes,
the buddy allocator is used to allocate memory.
memac::Allocator<memac::pager::PageManager>
means that
the allocator uses the page manager to allocate slabs.
If a requested size is greater than (65512 - 8) bytes,
the page manager is used to allocate memory.
If a requested size is greater that 64K bytes,
the allocation will fail.