mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 22:41:06 +00:00
Merge pull request #214 from paritytech/dk-pwasm-alloc-fix
Fixes `WasmAllocator` to reflect recent nightly API changes
This commit is contained in:
@@ -9,7 +9,7 @@ crate-type = ["cdylib"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
polkadot-parachain = { path = "../../", default-features = false }
|
polkadot-parachain = { path = "../../", default-features = false }
|
||||||
wee_alloc = "0.4.0"
|
wee_alloc = { git = "https://github.com/rustwasm/wee_alloc", rev = "4e9f23fff1f2474962085ca693f8884db666889f" }
|
||||||
tiny-keccak = "1.4"
|
tiny-keccak = "1.4"
|
||||||
pwasm-libc = "0.2"
|
pwasm-libc = "0.2"
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
//! Basic parachain that adds a number as part of its state.
|
//! Basic parachain that adds a number as part of its state.
|
||||||
|
|
||||||
#![cfg_attr(not(feature = "std"), no_std)]
|
#![cfg_attr(not(feature = "std"), no_std)]
|
||||||
#![cfg_attr(not(feature = "std"), feature(alloc, core_intrinsics, global_allocator, lang_items, panic_implementation))]
|
#![cfg_attr(not(feature = "std"), feature(alloc, core_intrinsics, lang_items, panic_implementation))]
|
||||||
|
|
||||||
#[cfg(not(feature = "std"))]
|
#[cfg(not(feature = "std"))]
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|||||||
@@ -2,9 +2,6 @@
|
|||||||
#![cfg_attr(feature = "strict", deny(warnings))]
|
#![cfg_attr(feature = "strict", deny(warnings))]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![crate_type = "rlib"]
|
#![crate_type = "rlib"]
|
||||||
#![cfg_attr(feature = "nightly", feature(global_allocator))]
|
|
||||||
#![cfg_attr(feature = "nightly", feature(alloc))]
|
|
||||||
#![cfg_attr(feature = "nightly", feature(allocator_api))]
|
|
||||||
|
|
||||||
//! Custom allocator crate for wasm
|
//! Custom allocator crate for wasm
|
||||||
|
|
||||||
@@ -17,19 +14,18 @@ static ALLOCATOR: WasmAllocator = WasmAllocator;
|
|||||||
|
|
||||||
#[cfg(feature = "nightly")]
|
#[cfg(feature = "nightly")]
|
||||||
mod __impl {
|
mod __impl {
|
||||||
extern crate alloc;
|
|
||||||
extern crate pwasm_libc;
|
extern crate pwasm_libc;
|
||||||
|
|
||||||
use self::alloc::heap::{GlobalAlloc, Layout, Opaque};
|
use core::alloc::{GlobalAlloc, Layout};
|
||||||
|
|
||||||
use super::WasmAllocator;
|
use super::WasmAllocator;
|
||||||
|
|
||||||
unsafe impl GlobalAlloc for WasmAllocator {
|
unsafe impl GlobalAlloc for WasmAllocator {
|
||||||
unsafe fn alloc(&self, layout: Layout) -> *mut Opaque {
|
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
|
||||||
pwasm_libc::malloc(layout.size()) as *mut Opaque
|
pwasm_libc::malloc(layout.size()) as *mut u8
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn dealloc(&self, ptr: *mut Opaque, _layout: Layout) {
|
unsafe fn dealloc(&self, ptr: *mut u8, _layout: Layout) {
|
||||||
pwasm_libc::free(ptr as *mut u8)
|
pwasm_libc::free(ptr as *mut u8)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user