kernel/mem_pool.c
/**
 *
 * @brief Return an allocated block to its block set
 *
 * @param ptr pointer to start of block
 * @param pool memory pool descriptor
 * @param index block set identifier
 *
 * @return N/A
 */
@brief Return an allocated block to its block set
@param ptr pointer to start of block
@param pool memory pool descriptor
@param index block set identifier

@return N/A
@brief Return an allocated block to its block set @param ptr pointer to start of block @param pool memory pool descriptor @param index block set identifier @return N / A
static void free_existing_block(char *ptr, struct k_mem_pool *pool, int index)
{
	struct k_mem_pool_quad_block *quad_block =
		pool->block_set[index].quad_block;
	char *block_ptr;
	u32_t i, j;
	for (i = 0; ; i++) {
		__ASSERT((i < pool->block_set[index].nr_of_entries) &&
			 (quad_block[i].mem_blocks != NULL),
			 "Attempt to free unallocated memory pool block\n");
		block_ptr = quad_block[i].mem_blocks;
		for (j = 0; j < 4; j++) {
			if (ptr == block_ptr) {
				quad_block[i].mem_status |= (1 << j);
				return;
			}
			block_ptr += OCTET_TO_SIZEOFUNIT(
				pool->block_set[index].block_size);
		}
	}
}
static void free_existing_block ( char * ptr , struct k_mem_pool * pool , int index ) { struct k_mem_pool_quad_block * quad_block = pool -> block_set [ index ] . quad_block ; char * block_ptr ; u32_t i , j ; for ( i = 0 ; ; i ++ ) { __ASSERT ( ( i < pool -> block_set [ index ] . nr_of_entries ) && ( quad_block [ i ] . mem_blocks != NULL ) , " \n " ) ; block_ptr = quad_block [ i ] . mem_blocks ; for ( j = 0 ; j < 4 ; j ++ ) { if ( ptr == block_ptr ) { quad_block [ i ] . mem_status |= ( 1 << j ) ; return ; } block_ptr += OCTET_TO_SIZEOFUNIT ( pool -> block_set [ index ] . block_size ) ; } } }
@brief Return an allocated block to its block set
 @param ptr pointer to start of block
 @param pool memory pool descriptor
 @param index block set identifier
@brief Return an allocated block to its block set @param ptr pointer to start of block @param pool memory pool descriptor @param index block set identifier
/*
	 * search block set's quad-blocks until the block is located,
	 * then mark it as unused
	 *
	 * note: block *must* exist, so no need to do array bounds checking
	 */