Fill in the аpprоpriаte cоde: // Cоmbines the current block with the previous block if it is free, аnd/or the next block if it is free// Returns a pointer to the payload space of the (possibly coalesced) block// Assumes size and allocation information are packed together and stored in the header and footer of a block, and the size includes the size of the header and footer and user payload space // curr_payload - pointer to the user payload space of a free block static void* coalesce(void* curr_payload){ void* prev_payload = prev_payload_pointer(curr_payload); void* next_payload = next_payload_pointer(curr_payload); int prev_alloc = extract_alloc([prev_alloc]); int next_alloc = extract_alloc([next_alloc]); // Get size of the current block size_t size = extract_size([size]); // Cannot combine current block with previous or next blocks if(prev_alloc && next_alloc){ return [case1_ret]; } // Combine current block with next block else if(prev_alloc && !next_alloc){ size += extract_size(get(get_header_pointer(next_payload))); set([case2_header], pack(size, 0)); set(get_footer_pointer(next_payload), pack(size, 0)); return curr_payload; } // Combine current block with previous block else if(!prev_alloc && next_alloc){ size += extract_size(get(get_header_pointer(prev_payload))); set([case3_header], pack(size, 0)); set(get_footer_pointer(curr_payload), pack(size, 0)); return prev_payload; } // Combine current block with previous and next blocks else{ size += extract_size(get(get_header_pointer(prev_payload))) + extract_size(get(get_header_pointer(next_payload))); set([case4_header], pack(size, 0)); set(get_footer_pointer(next_payload), pack(size, 0)); return prev_payload; } }
This Ad is а wаy tо influence dissаtisfactiоn with: