Complete the code to define the size of each block in the memory pool.
const size_t block_size = [1];The block size is set to 128 bytes, which is a common fixed size for memory pool blocks.
Complete the code to initialize the memory pool array with the correct total size.
static unsigned char memory_pool[[1]];The memory pool is sized to hold 30 blocks, each of block_size bytes.
Fix the error in the function that allocates a block from the pool by completing the condition to check if a free block is available.
if (free_list_head [1] NULL) { // allocate block }
The condition checks if the free list head is not NULL, meaning there is a free block to allocate.
Fill both blanks to correctly update the free list head after allocating a block.
allocated_block = free_list_head; free_list_head = [1]; allocated_block->next = [2];
After allocation, the free list head moves to the next free block, and the allocated block's next pointer is set to NULL.
Fill all three blanks to correctly add a freed block back to the free list.
void free_block(Block* block) {
// Optional: clear block data
memset(block, 0, [3]);
block->next = [1];
[2] = block;
}The freed block's next pointer is set to the current free list head, then the free list head is updated to the freed block. Clearing the block data uses sizeof(Block).