File tree 2 files changed +20
-1
lines changed
2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change 28
28
- The ` Display ` impl for ` CStr8 ` now excludes the trailing null character.
29
29
- ` VariableKeys ` initializes with a larger name buffer to work around firmware
30
30
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
32
32
allocations.
33
+ - The UEFI ` allocator::Allocator ` now implements ` core::alloc::Allocator `
34
+ (` allocator_api ` ), when the ` --unstable ` feature is used.
33
35
34
36
35
37
# 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};
20
20
use core:: sync:: atomic:: { AtomicU32 , Ordering } ;
21
21
use uefi_raw:: table:: boot:: PAGE_SIZE ;
22
22
23
+ #[ cfg( feature = "unstable" ) ]
24
+ use core:: alloc as alloc_api;
25
+
23
26
/// Get the memory type to use for allocation.
24
27
///
25
28
/// The first time this is called, the data type of the loaded image will be
@@ -160,3 +163,17 @@ unsafe impl GlobalAlloc for Allocator {
160
163
}
161
164
}
162
165
}
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