memkit 0.2.0-beta.1

Deterministic, intent-driven memory allocation for systems requiring predictable performance
Documentation
use memkit::{MkAllocator, MkConfig};

#[test]
fn test_allocator_handle_stability() {
    let alloc = MkAllocator::new(MkConfig::default());
    
    // Allocate from frame (this is the key use case)
    alloc.begin_frame();
    let box1 = alloc.frame_box(42u32).unwrap();
    let ptr = box1.as_ptr() as *mut u8;
    
    let handle = alloc.handle_alloc(ptr);
    assert_eq!(alloc.handle_resolve(handle), Some(ptr));
    
    // End frame - memory is technically invalid if it was ONLY on frame
    // but the handle still resolves to the pointer.
    alloc.end_frame();
    assert_eq!(alloc.handle_resolve(handle), Some(ptr));
    
    // In a real scenario, we might move the data to a new frame or heap
    // and update the handle.
    let box2 = alloc.heap_box(42u32).unwrap();
    let new_ptr = box2.as_ptr() as *mut u8;
    alloc.handle_update(handle, new_ptr);
    
    assert_eq!(alloc.handle_resolve(handle), Some(new_ptr));
    
    alloc.handle_free(handle);
    assert_eq!(alloc.handle_resolve(handle), None);
}