zephyr::raw

Function k_mem_slab_init

source
pub unsafe extern "C" fn k_mem_slab_init(
    slab: *mut k_mem_slab,
    buffer: *mut c_void,
    block_size: usize,
    num_blocks: u32,
) -> i32
Expand description

@brief Initialize a memory slab.

Initializes a memory slab, prior to its first use.

The memory slab’s buffer contains @a slab_num_blocks memory blocks that are @a slab_block_size bytes long. The buffer must be aligned to an N-byte boundary matching a word boundary, where N is a power of 2 (i.e. 4 on 32-bit systems, 8, 16, …). To ensure that each memory block is similarly aligned to this boundary, @a slab_block_size must also be a multiple of N.

@param slab Address of the memory slab. @param buffer Pointer to buffer used for the memory blocks. @param block_size Size of each memory block (in bytes). @param num_blocks Number of memory blocks.

@retval 0 on success @retval -EINVAL invalid data supplied