mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-11 01:21:07 +00:00
Compile polkadot-runtime both for Wasm ad native, allowing for testing and direct usage.
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
#![warn(missing_docs)]
|
||||
#![cfg_attr(feature = "strict", deny(warnings))]
|
||||
#![no_std]
|
||||
#![crate_type = "rlib"]
|
||||
#![feature(global_allocator)]
|
||||
#![feature(alloc)]
|
||||
#![feature(allocator_api)]
|
||||
|
||||
//! Custom allocator crate for wasm
|
||||
|
||||
extern crate alloc;
|
||||
extern crate pwasm_libc;
|
||||
|
||||
use alloc::heap::{Alloc, Layout, AllocErr};
|
||||
|
||||
/// Wasm allocator
|
||||
pub struct WasmAllocator;
|
||||
|
||||
unsafe impl<'a> Alloc for &'a WasmAllocator {
|
||||
unsafe fn alloc(&mut self, layout: Layout) -> Result<*mut u8, AllocErr> {
|
||||
Ok(pwasm_libc::malloc(layout.size()))
|
||||
}
|
||||
|
||||
unsafe fn dealloc(&mut self, ptr: *mut u8, _layout: Layout) {
|
||||
pwasm_libc::free(ptr)
|
||||
}
|
||||
}
|
||||
|
||||
#[global_allocator]
|
||||
static ALLOCATOR: WasmAllocator = WasmAllocator;
|
||||
Reference in New Issue
Block a user