Skip to content

Commit a53ede1

Browse files
committed
Rename nightly allocator API fns
1 parent 7e9d325 commit a53ede1

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

nucleus/src/mm/bump_allocator.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use {
99
crate::println,
1010
core::{
11-
alloc::{AllocError, AllocRef, Layout},
11+
alloc::{AllocError, Allocator, Layout},
1212
cell::Cell,
1313
ptr::NonNull,
1414
},
@@ -20,9 +20,9 @@ pub struct BumpAllocator {
2020
name: &'static str,
2121
}
2222

23-
unsafe impl AllocRef for BumpAllocator {
23+
unsafe impl Allocator for BumpAllocator {
2424
/// Allocate a memory block from the pool.
25-
fn alloc(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> {
25+
fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> {
2626
let start = crate::mm::aligned_addr_unchecked(self.next.get(), layout.align());
2727
let end = start + layout.size();
2828

@@ -50,7 +50,7 @@ unsafe impl AllocRef for BumpAllocator {
5050
}
5151

5252
/// A bump allocator doesn't care about releasing memory.
53-
unsafe fn dealloc(&self, _ptr: NonNull<u8>, _layout: Layout) {}
53+
unsafe fn deallocate(&self, _ptr: NonNull<u8>, _layout: Layout) {}
5454
}
5555

5656
impl BumpAllocator {
@@ -73,20 +73,20 @@ mod tests {
7373
#[test_case]
7474
fn test_allocates_within_init_range() {
7575
let allocator = BumpAllocator::new(256, 512, "Test allocator 1");
76-
let result1 = allocator.alloc(unsafe { Layout::from_size_align_unchecked(128, 1) });
76+
let result1 = allocator.allocate(unsafe { Layout::from_size_align_unchecked(128, 1) });
7777
assert!(result1.is_ok());
78-
let result2 = allocator.alloc(unsafe { Layout::from_size_align_unchecked(128, 32) });
78+
let result2 = allocator.allocate(unsafe { Layout::from_size_align_unchecked(128, 32) });
7979
println!("{:?}", result2);
8080
assert!(result2.is_ok());
81-
let result3 = allocator.alloc(unsafe { Layout::from_size_align_unchecked(1, 1) });
81+
let result3 = allocator.allocate(unsafe { Layout::from_size_align_unchecked(1, 1) });
8282
assert!(result3.is_err());
8383
}
8484
// Creating with end <= start sshould fail
8585
// @todo return Result<> from new?
8686
#[test_case]
8787
fn test_bad_allocator() {
8888
let bad_allocator = BumpAllocator::new(512, 256, "Test allocator 2");
89-
let result1 = bad_allocator.alloc(unsafe { Layout::from_size_align_unchecked(1, 1) });
89+
let result1 = bad_allocator.allocate(unsafe { Layout::from_size_align_unchecked(1, 1) });
9090
assert!(result1.is_err());
9191
}
9292
}

nucleus/src/platform/rpi3/mailbox.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -358,10 +358,10 @@ impl PreparedMailbox {
358358
impl Mailbox {
359359
/// Create a new mailbox in the DMA-able memory area.
360360
pub fn new(base_addr: usize) -> ::core::result::Result<Mailbox, ()> {
361-
use core::alloc::AllocRef;
361+
use core::alloc::Allocator;
362362
crate::DMA_ALLOCATOR
363363
.lock(|dma| {
364-
dma.alloc_zeroed(
364+
dma.allocate_zeroed(
365365
core::alloc::Layout::from_size_align(
366366
MAILBOX_ITEMS_COUNT * core::mem::size_of::<u32>(),
367367
MAILBOX_ALIGNMENT,

0 commit comments

Comments
 (0)