File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,10 @@ page-alloc-64g = []
2626page-alloc-4g = []
2727page-alloc-256m = []
2828
29+ axerrno = [" dep:axerrno" ]
30+
2931[dependencies ]
32+ axerrno = { version = " 0.1" , optional = true }
3033cfg-if = " 1.0"
3134rlsf = { version = " 0.2" , optional = true }
3235buddy_system_allocator = { version = " 0.10" , default-features = false , optional = true }
Original file line number Diff line number Diff line change @@ -34,6 +34,9 @@ pub use tlsf::TlsfByteAllocator;
3434use core:: alloc:: Layout ;
3535use core:: ptr:: NonNull ;
3636
37+ #[ cfg( feature = "axerrno" ) ]
38+ use axerrno:: AxError ;
39+
3740/// The error type used for allocation.
3841#[ derive( Debug ) ]
3942pub enum AllocError {
@@ -47,6 +50,16 @@ pub enum AllocError {
4750 NotAllocated ,
4851}
4952
53+ #[ cfg( feature = "axerrno" ) ]
54+ impl From < AllocError > for AxError {
55+ fn from ( value : AllocError ) -> Self {
56+ match value {
57+ AllocError :: NoMemory => AxError :: NoMemory ,
58+ _ => AxError :: InvalidInput ,
59+ }
60+ }
61+ }
62+
5063/// A [`Result`] type with [`AllocError`] as the error type.
5164pub type AllocResult < T = ( ) > = Result < T , AllocError > ;
5265
You can’t perform that action at this time.
0 commit comments