Skip to content

Commit aed64cc

Browse files
committed
Run rustfmt
1 parent 84f29a9 commit aed64cc

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/hole.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ impl HoleList {
4343
/// Searches the list for a big enough hole. A hole is big enough if it can hold an allocation
4444
/// of `size` bytes with the given `align`. If such a hole is found in the list, a block of the
4545
/// required size is allocated from it. Then the start address of that block is returned.
46-
/// This function uses the “first fit” strategy, so it uses the first hole that is big enough.
47-
/// Thus the runtime is in O(n) but it should be reasonably fast for small allocations.
46+
/// This function uses the “first fit” strategy, so it uses the first hole that is big
47+
/// enough. Thus the runtime is in O(n) but it should be reasonably fast for small allocations.
4848
pub fn allocate_first_fit(&mut self, size: usize, align: usize) -> Option<*mut u8> {
4949
assert!(size >= Self::min_size());
5050

@@ -136,10 +136,11 @@ fn split_hole(hole: HoleInfo, required_size: usize, required_align: usize) -> Op
136136
} else {
137137
// the required alignment causes some padding before the allocation
138138
let aligned_addr = align_up(hole.addr + HoleList::min_size(), required_align);
139-
(aligned_addr, Some(HoleInfo {
140-
addr: hole.addr,
141-
size: aligned_addr - hole.addr,
142-
}))
139+
(aligned_addr,
140+
Some(HoleInfo {
141+
addr: hole.addr,
142+
size: aligned_addr - hole.addr,
143+
}))
143144
};
144145

145146
let aligned_hole = {
@@ -181,13 +182,13 @@ fn split_hole(hole: HoleInfo, required_size: usize, required_align: usize) -> Op
181182
/// enough if it can hold an allocation of `size` bytes with the given `align`. When a hole is used
182183
/// for an allocation, there may be some needed padding before and/or after the allocation. This
183184
/// padding is returned as part of the `Allocation`. The caller must take care of freeing it again.
184-
/// This function uses the “first fit” strategy, so it breaks as soon as a big enough hole is found
185-
/// (and returns it).
185+
/// This function uses the “first fit” strategy, so it breaks as soon as a big enough hole is
186+
/// found (and returns it).
186187
fn allocate_first_fit(mut previous: &mut Hole, size: usize, align: usize) -> Option<Allocation> {
187188
loop {
188-
let allocation: Option<Allocation> = previous.next.as_mut().and_then(|current| {
189-
split_hole(unsafe { current.get() }.info(), size, align)
190-
});
189+
let allocation: Option<Allocation> = previous.next
190+
.as_mut()
191+
.and_then(|current| split_hole(unsafe { current.get() }.info(), size, align));
191192
match allocation {
192193
Some(allocation) => {
193194
// hole is big enough, so remove it from the list by updating the previous pointer
@@ -251,7 +252,7 @@ fn deallocate(mut hole: &mut Hole, addr: usize, mut size: usize) {
251252
// after: ___XXX__FFFFYYYYY____ where F is the freed block
252253

253254
hole.next = hole.next_unwrap().next.take(); // remove the Y block
254-
size += next.size; // free the merged F/Y block in next iteration
255+
size += next.size; // free the merged F/Y block in next iteration
255256
continue;
256257
}
257258
Some(next) if next.addr <= addr => {

0 commit comments

Comments
 (0)