next up previous contents index
Next: 15.6.6 lmm_alloc_aligned: allocate memory Up: 15.6 API reference Previous: 15.6.4 lmm_remove_free: remove a

15.6.5 lmm_alloc: allocate memory

   

SYNOPSIS

#include <oskit/lmm.h>

void *lmm_alloc(lmm_t *lmm, oskit_size_t size, lmm_flags_t flags);

DESCRIPTION

This is the primary routine used to allocate memory from an LMM pool. It searches for a free memory block of the specified size and with the specified memory type requirements (indicated by the flags argument), and returns a pointer to the allocated memory block. If no memory block of sufficient size and proper type can be found, then this function returns NULL instead.

Note that unlike with malloc, the caller must keep track of the size of allocated blocks in order to allow them to be freed properly later.

PARAMETERS

lmm
The memory pool from which to allocate.
size
The number of contiguous bytes of memory needed.
flags
The memory type required for this allocation. For each bit set in the flags parameter, the corresponding bit in a region's flags word must also be set in order for the region to be considered for allocation. If the flags parameter is zero, memory will be allocated from any region.

RETURNS

Returns a pointer to the memory block allocated, or NULL if no sufficiently large block of the correct type is available. The returned memory block will be at least doubleword aligned, but no other alignment properties are guaranteed by this routine.



University of Utah Flux Research Group