File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -115,7 +115,7 @@ impl<const ORDER: usize> FrameAllocator<ORDER> {
115
115
}
116
116
}
117
117
118
- let result = self . free_list [ class] . iter ( ) . next ( ) . clone ( ) ;
118
+ let result = self . free_list [ class] . iter ( ) . next ( ) ;
119
119
if let Some ( result_ref) = result {
120
120
let result = * result_ref;
121
121
self . free_list [ class] . remove ( & result) ;
@@ -155,7 +155,7 @@ impl<const ORDER: usize> FrameAllocator<ORDER> {
155
155
let mut current_class = class;
156
156
while current_class < self . free_list . len ( ) {
157
157
let buddy = current_ptr ^ ( 1 << current_class) ;
158
- if self . free_list [ current_class] . remove ( & buddy) == true {
158
+ if self . free_list [ current_class] . remove ( & buddy) {
159
159
// Free buddy found
160
160
current_ptr = min ( current_ptr, buddy) ;
161
161
current_class += 1 ;
Original file line number Diff line number Diff line change @@ -10,7 +10,9 @@ extern crate spin;
10
10
11
11
extern crate alloc;
12
12
13
- use core:: alloc:: { GlobalAlloc , Layout } ;
13
+ #[ cfg( feature = "use_spin" ) ]
14
+ use core:: alloc:: GlobalAlloc ;
15
+ use core:: alloc:: Layout ;
14
16
use core:: cmp:: { max, min} ;
15
17
use core:: fmt;
16
18
use core:: mem:: size_of;
@@ -76,7 +78,7 @@ impl<const ORDER: usize> Heap<ORDER> {
76
78
pub unsafe fn add_to_heap ( & mut self , mut start : usize , mut end : usize ) {
77
79
// avoid unaligned access on some platforms
78
80
start = ( start + size_of :: < usize > ( ) - 1 ) & ( !size_of :: < usize > ( ) + 1 ) ;
79
- end = end & ( !size_of :: < usize > ( ) + 1 ) ;
81
+ end &= !size_of :: < usize > ( ) + 1 ;
80
82
assert ! ( start <= end) ;
81
83
82
84
let mut total = 0 ;
@@ -338,5 +340,5 @@ unsafe impl<const ORDER: usize> GlobalAlloc for LockedHeapWithRescue<ORDER> {
338
340
}
339
341
340
342
pub ( crate ) fn prev_power_of_two ( num : usize ) -> usize {
341
- 1 << ( 8 * ( size_of :: < usize > ( ) ) - num. leading_zeros ( ) as usize - 1 )
343
+ 1 << ( usize :: BITS as usize - num. leading_zeros ( ) as usize - 1 )
342
344
}
You can’t perform that action at this time.
0 commit comments