#![allow(missing_docs)]
#![allow(clippy::doc_markdown)]
use taktora_bounded_alloc::declare_global_allocator;
const MAX_BLOCKS: usize = 16;
const BLOCK_SIZE: usize = 4096;
declare_global_allocator!(ALLOC, MAX_BLOCKS, BLOCK_SIZE);
fn main() {
println!("taktora-bounded-alloc fail_closed demo");
println!("arena: {MAX_BLOCKS} blocks × {BLOCK_SIZE} bytes");
println!(
"blocks already in use after Rust runtime startup: {}",
ALLOC.live_blocks()
);
println!();
let mut held: Vec<Box<[u8; 1024]>> = Vec::new();
for i in 0_u32..64 {
let b: Box<[u8; 1024]> = Box::new([(i & 0xff) as u8; 1024]);
held.push(b);
println!(
"iter {i}: alloc_count={}, live={}, peak={}, held={}",
ALLOC.alloc_count(),
ALLOC.live_blocks(),
ALLOC.peak_blocks_used(),
held.len()
);
}
println!("unexpectedly reached end of main (cap was not exhausted)");
}