@@ -240,13 +240,6 @@ fn deallocate(mut hole: &mut Hole, addr: usize, mut size: usize) {
240
240
hole. size += size + next. size ; // merge the F and Y blocks to this X block
241
241
hole. next = hole. next_unwrap ( ) . next . take ( ) ; // remove the Y block
242
242
}
243
- Some ( _) if hole_addr + hole. size == addr => {
244
- // block is right behind this hole but there is used memory after it
245
- // before: ___XXX______YYYYY____ where X is this hole and Y the next hole
246
- // after: ___XXXFFFF__YYYYY____ where F is the freed block
247
-
248
- hole. size += size; // merge the F block to this X block
249
- }
250
243
Some ( next) if addr + size == next. addr => {
251
244
// block is right before the next hole but there is used memory before it
252
245
// before: ___XXX______YYYYY____ where X is this hole and Y the next hole
@@ -264,6 +257,17 @@ fn deallocate(mut hole: &mut Hole, addr: usize, mut size: usize) {
264
257
hole = move_helper ( hole) . next_unwrap ( ) ; // start next iteration at next hole
265
258
continue ;
266
259
}
260
+ _ if hole_addr + hole. size == addr => {
261
+ // block is right behind this hole but there is used memory after it
262
+ // before: ___XXX______YYYYY____ where X is this hole and Y the next hole
263
+ // after: ___XXXFFFF__YYYYY____ where F is the freed block
264
+
265
+ // or: block is right behind this hole and this is the last hole
266
+ // before: ___XXX_______________ where X is this hole and Y the next hole
267
+ // after: ___XXXFFFF___________ where F is the freed block
268
+
269
+ hole. size += size; // merge the F block to this X block
270
+ }
267
271
_ => {
268
272
// block is between this and the next hole
269
273
// before: ___XXX________YYYYY_ where X is this hole and Y the next hole
0 commit comments