ckb-std 0.1.1

This library contains serveral modules help you write CKB contract with Rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use alloc::alloc::{Layout, GlobalAlloc};

extern "C" {
    fn malloc(size: usize) -> *mut u8;
    fn free(ptr: *mut u8);
}

pub struct LibCAlloc;

unsafe impl GlobalAlloc for LibCAlloc {
    unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
        malloc(layout.size())
    }
    unsafe fn dealloc(&self, ptr: *mut u8, _layout: Layout) {
        free(ptr)
    }
}