haz-alloc 0.3.1

A general-purpose allocator written in Rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use haz_alloc::Alloc;
use haz_alloc_core::__internal::SMALL_CLASSES;
use std::alloc::Layout;

static ALLOC: Alloc = Alloc::new();

#[test]
fn test_small() {
    unsafe {
        // classes
        for size0 in SMALL_CLASSES {
            let p = ALLOC.alloc_zeroed(Layout::from_size_align(*size0, 8).unwrap()) as *mut u64;
            assert_eq!(*p, 0);
            assert_eq!(ALLOC.size(p as _), *size0);
            ALLOC.dealloc(p as _);
        }
    }
}