rust-profanos 1.0.3

A lib to be able to code in rust into profanOS
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use core::alloc::{GlobalAlloc, Layout};

use crate::libs::libc::{free, malloc};

pub struct MemoryAllocator;

unsafe impl GlobalAlloc for MemoryAllocator {
    unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
        unsafe { malloc(layout.size() as usize) }
    }

    unsafe fn dealloc(&self, ptr: *mut u8, _layout: Layout) {
        unsafe { free(ptr) };
    }
}

#[global_allocator]
static ALLOCATOR: MemoryAllocator = MemoryAllocator;