File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change 2828- The ` Display ` impl for ` CStr8 ` now excludes the trailing null character.
2929- ` VariableKeys ` initializes with a larger name buffer to work around firmware
3030 bugs on some devices.
31- - The UEFI ` allocator::Allocator ` has been optimized for page-aligned
31+ - The UEFI ` allocator::Allocator ` has been optimized for page-aligned
3232 allocations.
33+ - The UEFI ` allocator::Allocator ` now implements ` core::alloc::Allocator `
34+ (` allocator_api ` ), when the ` --unstable ` feature is used.
3335
3436
3537# uefi - 0.34.1 (2025-02-07)
Original file line number Diff line number Diff line change @@ -20,6 +20,9 @@ use core::ptr::{self, NonNull};
2020use core:: sync:: atomic:: { AtomicU32 , Ordering } ;
2121use uefi_raw:: table:: boot:: PAGE_SIZE ;
2222
23+ #[ cfg( feature = "unstable" ) ]
24+ use core:: alloc as alloc_api;
25+
2326/// Get the memory type to use for allocation.
2427///
2528/// The first time this is called, the data type of the loaded image will be
@@ -160,3 +163,17 @@ unsafe impl GlobalAlloc for Allocator {
160163 }
161164 }
162165}
166+
167+ #[ cfg( feature = "unstable" ) ]
168+ unsafe impl alloc_api:: Allocator for Allocator {
169+ fn allocate ( & self , layout : Layout ) -> Result < NonNull < [ u8 ] > , alloc_api:: AllocError > {
170+ let ptr = unsafe { <Allocator as GlobalAlloc >:: alloc ( self , layout) } ;
171+ NonNull :: new ( ptr)
172+ . ok_or ( alloc_api:: AllocError )
173+ . map ( |ptr| NonNull :: slice_from_raw_parts ( ptr, layout. size ( ) ) )
174+ }
175+
176+ unsafe fn deallocate ( & self , ptr : NonNull < u8 > , layout : Layout ) {
177+ unsafe { <Allocator as GlobalAlloc >:: dealloc ( self , ptr. as_ptr ( ) , layout) }
178+ }
179+ }
You can’t perform that action at this time.
0 commit comments