next up previous contents index
Next: 15.6.7 lmm_alloc_gen: allocate memory Up: 15.6 API reference Previous: 15.6.5 lmm_alloc: allocate memory

15.6.6 lmm_alloc_aligned: allocate memory with a specific alignment

 

SYNOPSIS

#include <oskit/lmm.h>

void *lmm_alloc_aligned(lmm_t *lmm, oskit_size_t size, lmm_flags_t flags, int align_bits, oskit_addr_t align_ofs);

DESCRIPTION

This routine allocates a memory block with specific alignment constraints. It works like lmm_alloc, except that it enforces the rule that the lowest align_bits bits of the address of the returned block must match the lowest align_bits of align_ofs. In other words, align_bits specifies an alignment boundary as a power of two, and align_ofs specifies an offset from ``natural'' alignment. If no memory block with the proper requirements can be found, then this function returns NULL instead.

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.
align_bits
The number of low bits of the returned memory block address that must match the corresponding bits in align_ofs.
align_ofs
The required offset from natural power-of-two alignment. If align_ofs is zero, then the returned memory block will be naturally aligned on a tex2html_wrap_inline33869 boundary.

RETURNS

Returns a pointer to the memory block allocated, or NULL if no memory block satisfying the specified requirements can be found.



University of Utah Flux Research Group