File tree Expand file tree Collapse file tree 3 files changed +18
-2
lines changed
Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Original file line number Diff line number Diff line change 4141- The ` Display ` impl for ` CStr8 ` now excludes the trailing null character.
4242- ` VariableKeys ` initializes with a larger name buffer to work around firmware
4343 bugs on some devices.
44- - The UEFI ` allocator::Allocator ` has been optimized for page-aligned
44+ - The UEFI ` allocator::Allocator ` has been optimized for page-aligned
4545 allocations.
46+ - The UEFI ` allocator::Allocator ` now implements ` core::alloc::Allocator `
47+ (` allocator_api ` ), when the ` unstable ` feature is used.
4648
4749
4850# uefi - 0.34.1 (2025-02-07)
Original file line number Diff line number Diff line change @@ -169,3 +169,17 @@ unsafe impl GlobalAlloc for Allocator {
169169 }
170170 }
171171}
172+
173+ #[ cfg( feature = "unstable" ) ]
174+ unsafe impl core:: alloc:: Allocator for Allocator {
175+ fn allocate ( & self , layout : Layout ) -> Result < NonNull < [ u8 ] > , alloc_api:: AllocError > {
176+ let ptr = unsafe { <Allocator as GlobalAlloc >:: alloc ( self , layout) } ;
177+ NonNull :: new ( ptr)
178+ . ok_or ( alloc_api:: AllocError )
179+ . map ( |ptr| NonNull :: slice_from_raw_parts ( ptr, layout. size ( ) ) )
180+ }
181+
182+ unsafe fn deallocate ( & self , ptr : NonNull < u8 > , layout : Layout ) {
183+ unsafe { <Allocator as GlobalAlloc >:: dealloc ( self , ptr. as_ptr ( ) , layout) }
184+ }
185+ }
Original file line number Diff line number Diff line change 212212//! [uefi-std-tr-issue]: https://github.com/rust-lang/rust/issues/100499
213213//! [unstable features]: https://doc.rust-lang.org/unstable-book/
214214
215- #![ cfg_attr( all ( feature = "unstable" , feature = "alloc" ) , feature( allocator_api) ) ]
215+ #![ cfg_attr( feature = "unstable" , feature( allocator_api) ) ]
216216#![ cfg_attr( docsrs, feature( doc_auto_cfg) ) ]
217217#![ no_std]
218218#![ deny(
You can’t perform that action at this time.
0 commit comments