wasm_rust_utils/prelude/
mod.rs

1use memalloc;
2use std::ffi::{CString};
3use std::os::raw::{c_char};
4
5#[no_mangle]
6pub fn alloc(size: usize) -> *mut u8 {
7    unsafe {
8        let ptr = memalloc::allocate(size);
9        ptr
10    }
11}
12
13#[no_mangle]
14pub fn dealloc(ptr: *mut u8, size: usize) {
15    unsafe  {
16        memalloc::deallocate(ptr as *mut u8, size);
17    }
18}
19
20#[no_mangle]
21pub fn dealloc_str(ptr: *mut c_char) {
22    unsafe {
23        let _ = CString::from_raw(ptr);
24    }
25}