next up previous contents index
Next: 15.6.4 lmm_remove_free: remove a Up: 15.6 API reference Previous: 15.6.2 lmm_add_region: register a

15.6.3 lmm_add_free: add a block of free memory to an LMM pool

   

SYNOPSIS

#include <oskit/lmm.h>

void lmm_add_free(lmm_t *lmm, void *block, oskit_size_t size);

DESCRIPTION

This routine declares a range of memory to be available for allocation, and attaches that memory to the specified LMM pool. The memory block will be made available to satisfy subsequent allocation requests.

The caller can specify a block of any size and alignment, as long as the block does not wrap around the end of the address space. The LMM may discard a few bytes at the beginning and end of the block in order to enforce internal alignment constraints; however, the LMM will never touch memory outside the specified block (unless, of course, that memory is part of another free block).

If the block's beginning or end happens to coincide exactly with the beginning or end of a block already on the free list, then the LMM will merge the new block with the existing one. Of course, the block may be further subdivided or merged later as memory is allocated from the pool and returned to it.

The new free block will automatically be associated with whatever region it happens to fall in. If the block crosses the boundary between two regions, then it is automatically split between the regions. If part of the block does not fall within any region, then that part of the block is simply ignored and forgotten about. (By extension, if the entire block does not overlap any region, the entire block is dropped on the floor.)

PARAMETERS

lmm
The LMM pool to add the free memory to.
block
The start address of the memory block to add. There are no alignment restrictions.
size
The size of the block to add, in bytes. There are no alignment restrictions, but the size must not be so large as to wrap around the end of the address space.


next up previous contents index
Next: 15.6.4 lmm_remove_free: remove a Up: 15.6 API reference Previous: 15.6.2 lmm_add_region: register a

University of Utah Flux Research Group