kernel/mem_pool.c
/**
 *
 * @brief Initialize the memory pool
 *
 * Initialize the internal memory accounting structures of the memory pool
 *
 * @param pool memory pool descriptor
 *
 * @return N/A
 */
@brief Initialize the memory pool
Initialize the internal memory accounting structures of the memory pool

@param pool memory pool descriptor

@return N/A
@brief Initialize the memory pool Initialize the internal memory accounting structures of the memory pool @param pool memory pool descriptor @return N / A
static void init_one_memory_pool(struct k_mem_pool *pool)
{
	int remaining_blocks = pool->nr_of_maxblocks;
	int j = 0;
	char *memptr = pool->bufblock;
	while (remaining_blocks >= 4) {
		pool->block_set[0].quad_block[j].mem_blocks = memptr;
		pool->block_set[0].quad_block[j].mem_status =
			_QUAD_BLOCK_AVAILABLE;
		j++;
		remaining_blocks -= 4;
		memptr +=
			OCTET_TO_SIZEOFUNIT(pool->block_set[0].block_size)
			* 4;
	}
	if (remaining_blocks != 0) {
		pool->block_set[0].quad_block[j].mem_blocks = memptr;
		pool->block_set[0].quad_block[j].mem_status =
			_QUAD_BLOCK_AVAILABLE >> (4 - remaining_blocks);
	}
	sys_dlist_init(&pool->wait_q);
	SYS_TRACING_OBJ_INIT(k_mem_pool, pool);
}
static void init_one_memory_pool ( struct k_mem_pool * pool ) { int remaining_blocks = pool -> nr_of_maxblocks ; int j = 0 ; char * memptr = pool -> bufblock ; while ( remaining_blocks >= 4 ) { pool -> block_set [ 0 ] . quad_block [ j ] . mem_blocks = memptr ; pool -> block_set [ 0 ] . quad_block [ j ] . mem_status = _QUAD_BLOCK_AVAILABLE ; j ++ ; remaining_blocks -= 4 ; memptr += OCTET_TO_SIZEOFUNIT ( pool -> block_set [ 0 ] . block_size ) * 4 ; } if ( remaining_blocks != 0 ) { pool -> block_set [ 0 ] . quad_block [ j ] . mem_blocks = memptr ; pool -> block_set [ 0 ] . quad_block [ j ] . mem_status = _QUAD_BLOCK_AVAILABLE >> ( 4 - remaining_blocks ) ; } sys_dlist_init ( & pool -> wait_q ) ; SYS_TRACING_OBJ_INIT ( k_mem_pool , pool ) ; }
@brief Initialize the memory pool
 Initialize the internal memory accounting structures of the memory pool
@brief Initialize the memory pool Initialize the internal memory accounting structures of the memory pool
/*
	 * mark block set for largest block size
	 * as owning all of the memory pool buffer space
	 */ /* non-existent blocks are marked as unavailable */ /*
	 * note: all other block sets own no blocks, since their
	 * first quad-block has a NULL memory pointer
	 */