Skip to content

Commit 8f8f585

Browse files
committed
Increase the size of the last hole if the new hole aligns to it
1 parent 9a3bb89 commit 8f8f585

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/hole.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,15 @@ fn deallocate(mut hole: &mut Hole, addr: usize, mut size: usize) {
240240
hole.size += size + next.size; // merge the F and Y blocks to this X block
241241
hole.next = hole.next_unwrap().next.take(); // remove the Y block
242242
}
243-
Some(_) if hole_addr + hole.size == addr => {
243+
_ if hole_addr + hole.size == addr => {
244244
// block is right behind this hole but there is used memory after it
245245
// before: ___XXX______YYYYY____ where X is this hole and Y the next hole
246246
// after: ___XXXFFFF__YYYYY____ where F is the freed block
247247

248+
// or: block is right behind this hole and this is the last hole
249+
// before: ___XXX_______________ where X is this hole and Y the next hole
250+
// after: ___XXXFFFF___________ where F is the freed block
251+
248252
hole.size += size; // merge the F block to this X block
249253
}
250254
Some(next) if addr + size == next.addr => {

0 commit comments

Comments
 (0)