use framealloc::{SmartAlloc, AllocConfig};
fn main() {
println!("=== framealloc Basic Usage ===\n");
let alloc = SmartAlloc::new(AllocConfig::default());
println!("1. Frame Allocation (fastest path)");
alloc.begin_frame();
let data = alloc.frame_box(42u64).expect("allocation failed");
println!(" Allocated frame_box with value: {}", *data);
let mut slice = alloc.frame_slice::<f32>(100).expect("slice allocation failed");
slice[0] = 3.14;
slice[99] = 2.71;
println!(" Allocated frame_slice with {} elements", slice.len());
alloc.end_frame();
println!(" Frame ended - all frame allocations invalidated\n");
println!("2. Pool Allocation (for small objects)");
{
let boxed = alloc.pool_box(123u64).expect("pool allocation failed");
println!(" Allocated pool_box with value: {}", *boxed);
}
println!(" pool_box automatically freed on drop\n");
println!("3. Heap Allocation (for large objects)");
{
let large = alloc.heap_box([0u8; 8192]).expect("heap allocation failed");
println!(" Allocated heap_box with {} bytes", large.len());
}
println!(" heap_box automatically freed on drop\n");
println!("4. Allocation Statistics");
let stats = alloc.stats();
println!(" Total allocated: {} bytes", stats.total_allocated);
println!(" Peak allocated: {} bytes", stats.peak_allocated);
println!(" Allocation count: {}", stats.allocation_count);
println!(" Deallocation count: {}", stats.deallocation_count);
println!("\n=== Done ===");
}