next up previous contents index
Next: 15.6.5 lmm_alloc: allocate memory Up: 15.6 API reference Previous: 15.6.3 lmm_add_free: add a

15.6.4 lmm_remove_free: remove a block of memory from an LMM pool

 

SYNOPSIS

#include <oskit/lmm.h>

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

DESCRIPTION

This routine is complementary to lmm_add_free: it removes all free memory blocks in a specified address range from an LMM memory pool. After this call completes, unless the caller subsequently adds memory in this range back onto the LMM pool using lmm_add_free or lmm_free it is guaranteed that no subsequent memory allocation will return a memory block that overlaps the specified range.

The address range specified to this routine does not actually all have to be on the free list. If the address range contains several smaller free memory blocks, then all of those free blocks are removed from the pool without touching or affecting any memory parts of the address range that weren't in the free memory list. Similarly, if a free block crosses the beginning or end of the range, then the free block is ``clipped'' so that the part previously extending into the address range is removed and thrown away.

One use for this routine is to reserve a specific piece of memory for some special purpose, and ensure that no subsequent allocations use that region. For example, the example MultiBoot boot loaders in the OSKit use this routine to reserve the address range that will eventually be occupied by the OS executable being loaded, ensuring that none of the information structures to be passed to the OS will overlap with the final position of its executable image.

This routine works by finding all the free memory in the given range and allocating it. This means that if blocks were allocated in that range before the lmm_remove_free call and then freed afterwords, then they will be candidates for future allocations.

PARAMETERS

lmm
The LMM pool from which to remove free memory.
block
The start address of the range in which to remove all free memory.
size
The size of the address range.


next up previous contents index
Next: 15.6.5 lmm_alloc: allocate memory Up: 15.6 API reference Previous: 15.6.3 lmm_add_free: add a

University of Utah Flux Research Group