Skip to content
Snippets Groups Projects
Commit aebfd382 authored by Sergey Pepyakin's avatar Sergey Pepyakin Committed by GitHub
Browse files

Merge pull request #214 from paritytech/dk-pwasm-alloc-fix

Fixes `WasmAllocator` to reflect recent nightly API changes
parents 4dc6af80 9b330fdc
No related merge requests found
......@@ -9,7 +9,7 @@ crate-type = ["cdylib"]
[dependencies]
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"
pwasm-libc = "0.2"
......
......@@ -17,7 +17,7 @@
//! Basic parachain that adds a number as part of its state.
#![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"))]
extern crate alloc;
......
......@@ -2,9 +2,6 @@
#![cfg_attr(feature = "strict", deny(warnings))]
#![no_std]
#![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
......@@ -17,19 +14,18 @@ static ALLOCATOR: WasmAllocator = WasmAllocator;
#[cfg(feature = "nightly")]
mod __impl {
extern crate alloc;
extern crate pwasm_libc;
use self::alloc::heap::{GlobalAlloc, Layout, Opaque};
use core::alloc::{GlobalAlloc, Layout};
use super::WasmAllocator;
unsafe impl GlobalAlloc for WasmAllocator {
unsafe fn alloc(&self, layout: Layout) -> *mut Opaque {
pwasm_libc::malloc(layout.size()) as *mut Opaque
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
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)
}
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment