File tree 3 files changed +12
-10
lines changed
3 files changed +12
-10
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
}
Original file line number Diff line number Diff line change 1
1
//! Provide the intrusive LinkedList
2
- #![ allow( dead_code) ]
3
2
3
+ use core:: marker:: PhantomData ;
4
4
use core:: { fmt, ptr} ;
5
5
6
6
/// An intrusive linked list
@@ -52,7 +52,7 @@ impl LinkedList {
52
52
pub fn iter ( & self ) -> Iter {
53
53
Iter {
54
54
curr : self . head ,
55
- list : self ,
55
+ list : PhantomData ,
56
56
}
57
57
}
58
58
@@ -61,7 +61,7 @@ impl LinkedList {
61
61
IterMut {
62
62
prev : & mut self . head as * mut * mut usize as * mut usize ,
63
63
curr : self . head ,
64
- list : self ,
64
+ list : PhantomData ,
65
65
}
66
66
}
67
67
}
@@ -75,7 +75,7 @@ impl fmt::Debug for LinkedList {
75
75
/// An iterator over the linked list
76
76
pub struct Iter < ' a > {
77
77
curr : * mut usize ,
78
- list : & ' a LinkedList ,
78
+ list : PhantomData < & ' a LinkedList > ,
79
79
}
80
80
81
81
impl < ' a > Iterator for Iter < ' a > {
@@ -117,7 +117,7 @@ impl ListNode {
117
117
118
118
/// A mutable iterator over the linked list
119
119
pub struct IterMut < ' a > {
120
- list : & ' a mut LinkedList ,
120
+ list : PhantomData < & ' a mut LinkedList > ,
121
121
prev : * mut usize ,
122
122
curr : * mut usize ,
123
123
}
You can’t perform that action at this time.
0 commit comments