improve wasm modules

This commit is contained in:
vms
2020-06-11 03:10:37 +03:00
parent f4022533b7
commit 255a131a4f
13 changed files with 118 additions and 36 deletions

View File

@ -23,7 +23,7 @@ use std::ptr::NonNull;
pub unsafe fn allocate(size: usize) -> NonNull<u8> {
let layout: Layout = Layout::from_size_align(size, std::mem::align_of::<u8>()).unwrap();
let msg = format!("wasm_rpc: calling allocate with {}\n", size);
let msg = format!("ipfs_rpc.allocate: {}\n", size);
log_utf8_string(msg.as_ptr() as _, msg.len() as _);
NonNull::new_unchecked(global_alloc(layout))
@ -34,7 +34,7 @@ pub unsafe fn allocate(size: usize) -> NonNull<u8> {
pub unsafe fn deallocate(ptr: NonNull<u8>, size: usize) {
let layout = Layout::from_size_align(size, std::mem::align_of::<u8>()).unwrap();
let msg = format!("wasm_rpc: calling deallocate with {:?} {}\n", ptr, size);
let msg = format!("ipfs_rpc.deallocate: {:?} {}\n", ptr, size);
log_utf8_string(msg.as_ptr() as _, msg.len() as _);
global_dealloc(ptr.as_ptr(), layout);