memac: Memory allocator using slab and buddy allocators

Usage

First of all, allocate 64KiB aligned memory regions for slab and buddy allocators.

```rust

![feature(start)]

use memac; use libc::{posixmemalign, cvoid};

[global_allocator]

static mut ALLOC: memac::Allocator = memac::Allocator::new();

fn main() { println!("Hello, world!"); }

const HEAP_SIZE: usize = 32 * 1024 * 1024; // 32MiB

[start]

fn start(argc: isize, _argv: *const *const u8) -> isize { // initialize memory unsafe { // allocate memory for the buddy allocator let mut ptr: *mut cvoid = std::ptr::nullmut(); if posixmemalign(&mut ptr, memalloc::ALIGNMENT, HEAPSIZE) != 0 { panic!("posixmemalign"); } ALLOC.init_buddy(ptr as usize);

    // allocate memory for the slab allocator
    let mut ptr: *mut c_void = std::ptr::null_mut();
    if posix_memalign(&mut ptr, memalloc::ALIGNMENT, HEAP_SIZE) != 0 {
        panic!("posix_memalign");
    }
    ALLOC.init_slab(ptr as usize, HEAP_SIZE);
}

main();
0

} ```

toml [dependencies] libc = "0.2" memac = { features=["buddy_32m"] }

buddy_32m indicates that the buddy allocator's memory size is 32MiB. If you want to change the size, see Cargo.toml.

Slab allocator's size can be determined by the init_slab function.