mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-28 07:51:07 +00:00
Merge pull request #947 from fitzgen/use-global-allocator-not-system
Use the global allocator, not the system allocator
This commit is contained in:
commit
35eeb711ad
@ -809,7 +809,7 @@ pub mod __rt {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if_std! {
|
if_std! {
|
||||||
use std::alloc::{System, GlobalAlloc, Layout};
|
use std::alloc::{alloc, dealloc, Layout};
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
@ -817,7 +817,7 @@ pub mod __rt {
|
|||||||
let align = mem::align_of::<usize>();
|
let align = mem::align_of::<usize>();
|
||||||
if let Ok(layout) = Layout::from_size_align(size, align) {
|
if let Ok(layout) = Layout::from_size_align(size, align) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let ptr = System.alloc(layout);
|
let ptr = alloc(layout);
|
||||||
if !ptr.is_null() {
|
if !ptr.is_null() {
|
||||||
return ptr
|
return ptr
|
||||||
}
|
}
|
||||||
@ -836,7 +836,7 @@ pub mod __rt {
|
|||||||
}
|
}
|
||||||
let align = mem::align_of::<usize>();
|
let align = mem::align_of::<usize>();
|
||||||
let layout = Layout::from_size_align_unchecked(size, align);
|
let layout = Layout::from_size_align_unchecked(size, align);
|
||||||
System.dealloc(ptr, layout);
|
dealloc(ptr, layout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user