|
@@ -112,17 +112,18 @@ bool coalesce(allocator_t *allocator, heap_t *heap, void *ptr) {
|
|
|
#endif /* COUNT_HOPS */
|
|
|
}
|
|
|
#endif /* WITH_FIXED_LISTS */
|
|
|
- /* Reset the previous block size */
|
|
|
- set_size_and_free(allocator, previous_block, three_blocks_size);
|
|
|
/* Remove the next block from any freelist */
|
|
|
remove_block_from_lists(&next_block, heap);
|
|
|
/* Update border pointer if the next block was the border pointer */
|
|
|
if(allocator->border_ptr == next_block) {
|
|
|
- allocator->border_ptr = ptr;
|
|
|
+ allocator->border_ptr = previous_block;
|
|
|
}
|
|
|
+ /* Reset the previous block size */
|
|
|
+ set_size_and_free(allocator, previous_block, three_blocks_size);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ /* Check if Previous + Current is ok */
|
|
|
if(previous_current_size <= max_coal_size) {
|
|
|
/* If previous block is on a fixed list, remove it */
|
|
|
#ifdef WITH_FIXED_LISTS
|
|
@@ -143,21 +144,22 @@ bool coalesce(allocator_t *allocator, heap_t *heap, void *ptr) {
|
|
|
#endif /* COUNT_HOPS */
|
|
|
}
|
|
|
#endif /* WITH_FIXED_LISTS */
|
|
|
- /* Reset the previous block size */
|
|
|
- set_size_and_free(allocator, ptr, previous_current_size);
|
|
|
/* Update border pointer if the current block was the border pointer */
|
|
|
- if(allocator->border_ptr == next_block) {
|
|
|
- allocator->border_ptr = ptr;
|
|
|
+ if(allocator->border_ptr == ptr) {
|
|
|
+ allocator->border_ptr = previous_block;
|
|
|
}
|
|
|
+ /* Reset the previous block size */
|
|
|
+ set_size_and_free(allocator, ptr, previous_current_size);
|
|
|
return true;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ /* Check if Current + Next is ok */
|
|
|
if(current_next_size <= max_coal_size) {
|
|
|
- set_size_and_free(allocator, ptr, current_next_size);
|
|
|
remove_block_from_lists(&next_block, heap);
|
|
|
if(allocator->border_ptr == next_block) {
|
|
|
allocator->border_ptr = ptr;
|
|
|
}
|
|
|
+ set_size_and_free(allocator, ptr, current_next_size);
|
|
|
return false;
|
|
|
}
|
|
|
|