File tree 3 files changed +18
-2
lines changed
3 files changed +18
-2
lines changed Original file line number Diff line number Diff line change 41
41
- The ` Display ` impl for ` CStr8 ` now excludes the trailing null character.
42
42
- ` VariableKeys ` initializes with a larger name buffer to work around firmware
43
43
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
45
45
allocations.
46
+ - The UEFI ` allocator::Allocator ` now implements ` core::alloc::Allocator `
47
+ (` allocator_api ` ), when the ` unstable ` feature is used.
46
48
47
49
48
50
# 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 {
169
169
}
170
170
}
171
171
}
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 212
212
//! [uefi-std-tr-issue]: https://github.com/rust-lang/rust/issues/100499
213
213
//! [unstable features]: https://doc.rust-lang.org/unstable-book/
214
214
215
- #![ cfg_attr( all ( feature = "unstable" , feature = "alloc" ) , feature( allocator_api) ) ]
215
+ #![ cfg_attr( feature = "unstable" , feature( allocator_api) ) ]
216
216
#![ cfg_attr( docsrs, feature( doc_auto_cfg) ) ]
217
217
#![ no_std]
218
218
#![ deny(
You can’t perform that action at this time.
0 commit comments