Skip to content

Commit 7d5d728

Browse files
committed
Run rustfmt
1 parent 4323d51 commit 7d5d728

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/lib.rs

+9-8
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,21 @@
4747
#![no_std]
4848
#![feature(alloc, allocator_api)]
4949

50+
extern crate alloc;
5051
extern crate cortex_m;
5152
extern crate linked_list_allocator;
52-
extern crate alloc;
5353

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

57-
use linked_list_allocator::Heap;
5857
use cortex_m::interrupt::Mutex;
58+
use linked_list_allocator::Heap;
5959

6060
pub struct CortexMHeap {
6161
heap: Mutex<Heap>,
6262
}
6363

6464
impl CortexMHeap {
65-
6665
/// Crate a new UNINITIALIZED heap allocator
6766
///
6867
/// You must initialize this heap using the
@@ -96,19 +95,21 @@ impl CortexMHeap {
9695
///
9796
/// - This function must be called exactly ONCE.
9897
/// - `size > 0`
99-
pub unsafe fn init(&self, start_addr: usize, size: usize){
98+
pub unsafe fn init(&self, start_addr: usize, size: usize) {
10099
self.heap.lock(|heap| heap.init(start_addr, size));
101100
}
102101
}
103102

104103
unsafe impl GlobalAlloc for CortexMHeap {
105104
unsafe fn alloc(&self, layout: Layout) -> *mut Opaque {
106-
self.heap.lock(|heap| {
107-
heap.allocate_first_fit(layout)
108-
}).ok().map_or(0 as *mut Opaque, |allocation| allocation.as_ptr())
105+
self.heap
106+
.lock(|heap| heap.allocate_first_fit(layout))
107+
.ok()
108+
.map_or(0 as *mut Opaque, |allocation| allocation.as_ptr())
109109
}
110110

111111
unsafe fn dealloc(&self, ptr: *mut Opaque, layout: Layout) {
112-
self.heap.lock(|heap| heap.deallocate(NonNull::new_unchecked(ptr), layout));
112+
self.heap
113+
.lock(|heap| heap.deallocate(NonNull::new_unchecked(ptr), layout));
113114
}
114115
}

0 commit comments

Comments
 (0)