|
@@ -20,6 +20,10 @@
|
|
|
#include "freelist/block_header_funcs.h"
|
|
|
#include "freelist/linked_lists/add_block.h"
|
|
|
|
|
|
+#ifdef COALESCE_AFTER_SPLIT
|
|
|
+#include "freelist/linked_lists/linked_lists.h" // for remove_block()
|
|
|
+#endif /* COALESCE_AFTER_SPLIT */
|
|
|
+
|
|
|
void split(freelist_rb_t *raw_block, block_header_t *ptr, size_t req_size) {
|
|
|
size_t new_size;
|
|
|
size_t min_split_size;
|
|
@@ -29,7 +33,7 @@ void split(freelist_rb_t *raw_block, block_header_t *ptr, size_t req_size) {
|
|
|
block_header_t *next_block;
|
|
|
size_t current_next_size;
|
|
|
|
|
|
- next_block = get_dlnext(allocator, ptr);
|
|
|
+ next_block = get_dlnext(raw_block, ptr);
|
|
|
#endif /* COALESCE_AFTER_SPLIT */
|
|
|
|
|
|
/* Check what would be the size of the new block if we split the current
|
|
@@ -72,20 +76,14 @@ void split(freelist_rb_t *raw_block, block_header_t *ptr, size_t req_size) {
|
|
|
max_coal_size = heap->dmm_knobs.max_coalesce_size;
|
|
|
#endif /* COALESCING_VARIABLE */
|
|
|
|
|
|
- if(next_block != (memory_block_ptr) NULL) {
|
|
|
- if(is_free(next_block) == true) {
|
|
|
- current_next_size = new_size + get_size(next_block) +
|
|
|
- HEADER_SIZE;
|
|
|
- if(current_next_size <= max_coal_size) {
|
|
|
- /* it's ok to coalesce the new split block with the next
|
|
|
- * free block
|
|
|
- */
|
|
|
- remove_block_from_lists(&next_block, heap);
|
|
|
- if(allocator->border_ptr == next_block) {
|
|
|
- allocator->border_ptr = ptr;
|
|
|
- }
|
|
|
- new_size = current_next_size;
|
|
|
+ if(next_block != NULL && is_free(next_block) == true) {
|
|
|
+ current_next_size = new_size + get_size(next_block) + HEADER_SIZE;
|
|
|
+ if(current_next_size <= max_coal_size) {
|
|
|
+ remove_block(next_block, raw_block);
|
|
|
+ if(raw_block->border_ptr == next_block) {
|
|
|
+ raw_block->border_ptr = new_block;
|
|
|
}
|
|
|
+ new_size = current_next_size;
|
|
|
}
|
|
|
}
|
|
|
|