@@ -27,11 +27,13 @@ impl HoleList {
2727 assert ! ( size_of:: <Hole >( ) == Self :: min_size( ) ) ;
2828
2929 let ptr = hole_addr as * mut Hole ;
30- mem:: replace ( & mut * ptr,
31- Hole {
32- size : hole_size,
33- next : None ,
34- } ) ;
30+ mem:: replace (
31+ & mut * ptr,
32+ Hole {
33+ size : hole_size,
34+ next : None ,
35+ } ,
36+ ) ;
3537
3638 HoleList {
3739 first : Hole {
@@ -79,7 +81,9 @@ impl HoleList {
7981 /// Returns information about the first hole for test purposes.
8082 #[ cfg( test) ]
8183 pub fn first_hole ( & self ) -> Option < ( usize , usize ) > {
82- self . first . next . as_ref ( ) . map ( |hole| ( hole. as_ptr ( ) as usize , unsafe { hole. as_ref ( ) . size } ) )
84+ self . first . next . as_ref ( ) . map ( |hole| {
85+ ( hole. as_ptr ( ) as usize , unsafe { hole. as_ref ( ) . size } )
86+ } )
8387 }
8488}
8589
@@ -141,11 +145,13 @@ fn split_hole(hole: HoleInfo, required_layout: Layout) -> Option<Allocation> {
141145 } else {
142146 // the required alignment causes some padding before the allocation
143147 let aligned_addr = align_up ( hole. addr + HoleList :: min_size ( ) , required_align) ;
144- ( aligned_addr,
145- Some ( HoleInfo {
146- addr : hole. addr ,
147- size : aligned_addr - hole. addr ,
148- } ) )
148+ (
149+ aligned_addr,
150+ Some ( HoleInfo {
151+ addr : hole. addr ,
152+ size : aligned_addr - hole. addr ,
153+ } ) ,
154+ )
149155 } ;
150156
151157 let aligned_hole = {
@@ -192,9 +198,9 @@ fn split_hole(hole: HoleInfo, required_layout: Layout) -> Option<Allocation> {
192198/// found (and returns it).
193199fn allocate_first_fit ( mut previous : & mut Hole , layout : Layout ) -> Result < Allocation , AllocErr > {
194200 loop {
195- let allocation: Option < Allocation > = previous. next
196- . as_mut ( )
197- . and_then ( |current| split_hole ( unsafe { current . as_ref ( ) } . info ( ) , layout . clone ( ) ) ) ;
201+ let allocation: Option < Allocation > = previous. next . as_mut ( ) . and_then ( |current| {
202+ split_hole ( unsafe { current . as_ref ( ) } . info ( ) , layout . clone ( ) )
203+ } ) ;
198204 match allocation {
199205 Some ( allocation) => {
200206 // hole is big enough, so remove it from the list by updating the previous pointer
@@ -207,9 +213,7 @@ fn allocate_first_fit(mut previous: &mut Hole, layout: Layout) -> Result<Allocat
207213 }
208214 None => {
209215 // this was the last hole, so no hole is big enough -> allocation not possible
210- return Err ( AllocErr :: Exhausted {
211- request : layout,
212- } ) ;
216+ return Err ( AllocErr :: Exhausted { request : layout } ) ;
213217 }
214218 }
215219 }
@@ -233,11 +237,15 @@ fn deallocate(mut hole: &mut Hole, addr: usize, mut size: usize) {
233237
234238 // Each freed block must be handled by the previous hole in memory. Thus the freed
235239 // address must be always behind the current hole.
236- assert ! ( hole_addr + hole. size <= addr,
237- "invalid deallocation (probably a double free)" ) ;
240+ assert ! (
241+ hole_addr + hole. size <= addr,
242+ "invalid deallocation (probably a double free)"
243+ ) ;
238244
239245 // get information about the next block
240- let next_hole_info = hole. next . as_ref ( ) . map ( |next| unsafe { next. as_ref ( ) . info ( ) } ) ;
246+ let next_hole_info = hole. next
247+ . as_ref ( )
248+ . map ( |next| unsafe { next. as_ref ( ) . info ( ) } ) ;
241249
242250 match next_hole_info {
243251 Some ( next) if hole_addr + hole. size == addr && addr + size == next. addr => {
0 commit comments