L4Re Operating System Framework – Interface and Usage Documentation
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)
 Allocate a memory block.
 
void * alloc_max (unsigned long min, unsigned long *max, unsigned long align, unsigned granularity)
 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 31 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 56 of file list_alloc.

Member Function Documentation

◆ alloc()

void * cxx::List_alloc::alloc ( unsigned long  size,
unsigned long  align 
)
inline

Allocate a memory block.

Parameters
sizeSize of the memory block.
alignAlignment constraint.
Returns
Pointer to memory block
Precondition
0 < size <= ~0UL - 32.

Definition at line 363 of file list_alloc.

◆ alloc_max()

void * cxx::List_alloc::alloc_max ( unsigned long  min,
unsigned long *  max,
unsigned long  align,
unsigned  granularity 
)
inline

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

Parameters
minMinimal size to allocate (in bytes).
[in,out]maxMaximum size to allocate (in bytes). The actual allocated size is returned here.
alignAlignment constraint.
granularityGranularity to use for the allocation (power of 2).
Returns
Pointer to memory block
Precondition
0 < min <= ~0UL - 32.
0 < max.

Definition at line 266 of file list_alloc.

References l4_round_size(), l4_trunc_size(), cxx::max(), and cxx::min().

+ 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 434 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
blockPointer to memory block.
sizeSize of memory block.
initial_freeSet 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 227 of file list_alloc.


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