malloc.c
static void split_block_if_necessary(union Header *block, size_t required_block_size)
{
	union Header *excess;
	size_t left_over;

	/* is there enough room to form a useful block (larger than just a header)? */
	left_over = block->h.size - required_block_size;
	if (left_over <= sizeof(union Header)) {
		return;
	}

	/* adjust size of the original block */
	block->h.size = required_block_size;

	/* compute address of block formed from excess memory in block */
	excess = (union Header *) (((char *) block) + required_block_size);

	/* initialize the new block's header */
	excess->h.size = left_over;
	excess->h.flags = 0;

	/* graft the new block into the list as current block's successor */
	excess->h.next = block->h.next;
	excess->h.prev = block;
	if (block->h.next != 0) {
		block->h.next->h.prev = excess;
	} else {
		/* splitting the tail block, so excess is new tail */
		s_tail = excess;
	}
	block->h.next = excess;
}
/*
 * Split given block if its excess space beyond given required block size
 * is large enough to form a useful block.
 */
Split given block if its excess space beyond given required block size
is large enough to form a useful block.
Split given block if its excess space beyond given required block size is large enough to form a useful block .
static void split_block_if_necessary(union Header *block, size_t required_block_size)
{
	union Header *excess;
	size_t left_over;
	left_over = block->h.size - required_block_size;
	if (left_over <= sizeof(union Header)) {
		return;
	}
	block->h.size = required_block_size;
	excess = (union Header *) (((char *) block) + required_block_size);
	excess->h.size = left_over;
	excess->h.flags = 0;
	excess->h.next = block->h.next;
	excess->h.prev = block;
	if (block->h.next != 0) {
		block->h.next->h.prev = excess;
	} else {
		s_tail = excess;
	}
	block->h.next = excess;
}
static void split_block_if_necessary ( union Header * block , size_t required_block_size ) { union Header * excess ; size_t left_over ; left_over = block -> h . size - required_block_size ; if ( left_over <= sizeof ( union Header ) ) { return ; } block -> h . size = required_block_size ; excess = ( union Header * ) ( ( ( char * ) block ) + required_block_size ) ; excess -> h . size = left_over ; excess -> h . flags = 0 ; excess -> h . next = block -> h . next ; excess -> h . prev = block ; if ( block -> h . next != 0 ) { block -> h . next -> h . prev = excess ; } else { s_tail = excess ; } block -> h . next = excess ; }
Split given block if its excess space beyond given required block size
 is large enough to form a useful block.
Split given block if its excess space beyond given required block size is large enough to form a useful block .
/* is there enough room to form a useful block (larger than just a header)? */ /* adjust size of the original block */ /* compute address of block formed from excess memory in block */ /* initialize the new block's header */ /* graft the new block into the list as current block's successor */ /* splitting the tail block, so excess is new tail */