Skip to content

Commit

Permalink
Merge pull request #947 from fitzgen/use-global-allocator-not-system
Browse files Browse the repository at this point in the history
Use the global allocator, not the system allocator
  • Loading branch information
alexcrichton committed Oct 10, 2018
2 parents d70149d + 3ceb044 commit 35eeb71
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -809,15 +809,15 @@ pub mod __rt {
}

if_std! {
use std::alloc::{System, GlobalAlloc, Layout};
use std::alloc::{alloc, dealloc, Layout};
use std::mem;

#[no_mangle]
pub extern fn __wbindgen_malloc(size: usize) -> *mut u8 {
let align = mem::align_of::<usize>();
if let Ok(layout) = Layout::from_size_align(size, align) {
unsafe {
let ptr = System.alloc(layout);
let ptr = alloc(layout);
if !ptr.is_null() {
return ptr
}
Expand All @@ -836,7 +836,7 @@ pub mod __rt {
}
let align = mem::align_of::<usize>();
let layout = Layout::from_size_align_unchecked(size, align);
System.dealloc(ptr, layout);
dealloc(ptr, layout);
}
}

Expand Down

0 comments on commit 35eeb71

Please sign in to comment.