Skip to content

Update to latest GlobalAlloc changes #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 20, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ extern crate alloc;
extern crate cortex_m;
extern crate linked_list_allocator;

use core::alloc::{GlobalAlloc, Layout, Opaque};
use core::alloc::{GlobalAlloc, Layout};
use core::ptr::NonNull;

use cortex_m::interrupt::Mutex;
Expand Down Expand Up @@ -104,14 +104,14 @@ impl CortexMHeap {
}

unsafe impl GlobalAlloc for CortexMHeap {
unsafe fn alloc(&self, layout: Layout) -> *mut Opaque {
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
self.heap
.lock(|heap| heap.allocate_first_fit(layout))
.ok()
.map_or(0 as *mut Opaque, |allocation| allocation.as_ptr())
.map_or(0 as *mut u8, |allocation| allocation.as_ptr())
}

unsafe fn dealloc(&self, ptr: *mut Opaque, layout: Layout) {
unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
self.heap
.lock(|heap| heap.deallocate(NonNull::new_unchecked(ptr), layout));
}
Expand Down