next up previous contents index
Next: 15.6.13 lmm_dump: display the Up: 15.6 API reference Previous: 15.6.11 lmm_avail: find the

15.6.12 lmm_find_free: scan a memory pool for free blocks

 

SYNOPSIS

#include <oskit/lmm.h>

void lmm_find_free(lmm_t *lmm, [in/out] oskit_addr_t *inout_addr, [out] oskit_size_t *out_size, [out] lmm_flags_t *out_flags);

DESCRIPTION

This routine can be used to locate free memory blocks in an LMM pool. It searches the pool for free memory starting at the address specified in *inout_addr, and returns a description of the lowest block of available memory starting at at least this address. The address and size of the next block found are returned in *inout_addr and *out_size, respectively, and the memory type flags associated with the region in which the block was found are returned in *out_flags. If no further free memory can be found above the specified address, then this routine returns with *out_size set to zero.

If the specified *inout_addr points into the middle of a free block, then a description of the remainder of the block is returned, i.e. the part of the block starting at *inout_addr and extending to the end of the free block.

This routine does not actually cause any memory to be allocated; it merely reports on available memory blocks. The caller must not actually attempt to use or modify any reported blocks without allocating them first. The caller can allocate a block reported by this routine using lmm_alloc_gen, using its in_min and in_size parameters to constrain the address of the allocated block to exactly the address reported by lmm_find_free. If this allocation is done immediately after the call to lmm_find_free, without any intervening memory allocations, then the allocation is guaranteed to succeed. However, any intervening memory allocation operations will effectively invalidate the information returned by this routine, and a subsequent attempt to allocate the reported block may fail.

PARAMETERS

lmm
The LMM pool in which to search for free memory.
inout_addr
On entry, the value pointed to by this parameter must be the address at which to start searching for free memory. On return, it contains the start address of the next free block actually found.
out_size
On return, the value pointed to by this parameter contains the size of the next free memory block found, or zero if no more free blocks could be located.
out_flags
On return, the value pointed to by this parameter contains the flags word associated with the region in which the next free memory block was found.


next up previous contents index
Next: 15.6.13 lmm_dump: display the Up: 15.6 API reference Previous: 15.6.11 lmm_avail: find the

University of Utah Flux Research Group