Loading...
Searching...
No Matches
cxx::List_alloc Class Reference

Standard list-based allocator. More...

`#include <list_alloc>`

Collaboration diagram for cxx::List_alloc:

## Public Member Functions

| List_alloc ()
| Initializes an empty list allocator.
void | free (void *block, unsigned long size, bool initial_free=false)
| Return a free memory block to the allocator.
void * | alloc (unsigned long size, unsigned long align, unsigned long lower=0, unsigned long upper=~0UL)
| Allocate a memory block.
void * | alloc_max (unsigned long min, unsigned long *max, unsigned long align, unsigned granularity, unsigned long lower=0, unsigned long upper=~0UL)
| Allocate a memory block of min <= size <= max.
unsigned long | avail ()
| Get the amount of available memory.

## Detailed Description

Standard list-based allocator.

Definition at line 21 of file list_alloc.

## Constructor & Destructor Documentation

## List_alloc()

cxx::List_alloc::List_alloc | ( |  | ) |

inline

Initializes an empty list allocator.

Note
  To initialize the allocator with available memory use the free() function.

Definition at line 46 of file list_alloc.

## Member Function Documentation

## alloc()

void * cxx::List_alloc::alloc | ( | unsigned long | size,
|  | unsigned long | align,
|  | unsigned long | lower = 0,
|  | unsigned long | upper = ~0UL )

inline

Allocate a memory block.

Parameters

  size | Size of the memory block.
  align | Alignment constraint.
  lower | Lower bound of the physical region the memory block should be allocated from.
  upper | Upper bound of the physical region the memory block should be allocated from, value is inclusive.

Returns
  Pointer to memory block

Precondition
  0 < size <= ~0UL - 32.

Definition at line 389 of file list_alloc.

## alloc_max()

void * cxx::List_alloc::alloc_max | ( | unsigned long | min,
|  | unsigned long * | max,
|  | unsigned long | align,
|  | unsigned | granularity,
|  | unsigned long | lower = 0,
|  | unsigned long | upper = ~0UL )

inline

Allocate a memory block of min <= size <= max.

Parameters

  | min | Minimal size to allocate (in bytes).
  [in,out] | max | Maximum size to allocate (in bytes). The actual allocated size is returned here.
  | align | Alignment constraint.
  | granularity | Granularity to use for the allocation (power of 2).
  | lower | Lower bound of the physical region the memory block should be allocated from.
  | upper | Upper bound of the physical region the memory block should be allocated from, value is inclusive.

Returns
  Pointer to memory block

Precondition
  0 < min <= ~0UL - 32.
  0 < max.

Definition at line 269 of file list_alloc.

References l4_round_size(), and l4_trunc_size().

Here is the call graph for this function:

## avail()

unsigned long cxx::List_alloc::avail | ( |  | ) |

inline

Get the amount of available memory.

Returns
  Available memory in bytes

Definition at line 477 of file list_alloc.

## free()

void cxx::List_alloc::free | ( | void * | block,
|  | unsigned long | size,
|  | bool | initial_free = false )

inline

Return a free memory block to the allocator.

Parameters

  block | Pointer to memory block.
  size | Size of memory block.
  initial_free | Set to true for putting fresh memory to the allocator. This will enforce alignment on that memory.

Precondition
  block must not be NULL.
  2 * sizeof(void *) <= size <= ~0UL - 32.

Definition at line 228 of file list_alloc.

The documentation for this class was generated from the following file:

- l4/cxx/list_alloc