RTEMS
Files | Classes | Typedefs | Functions
Freechain Handler

The Freechain Handler. More...

Files

file  freechain.h
 Freechain Handler API.
 
file  freechainimpl.h
 Freechain Handler API.
 

Classes

struct  Freechain_Control
 The freechain control. More...
 

Typedefs

typedef void *(* Freechain_Allocator) (size_t size)
 Allocator function.
 

Functions

static __inline__ void _Freechain_Initialize (Freechain_Control *freechain, void *initial_nodes, size_t number_nodes, size_t node_size)
 Initializes a freechain. More...
 
static __inline__ bool _Freechain_Is_empty (const Freechain_Control *freechain)
 Return true if the freechain is empty, otherwise false. More...
 
static __inline__ void * _Freechain_Pop (Freechain_Control *freechain)
 Pops a node from the freechain. More...
 
static void __inline__ _Freechain_Push (Freechain_Control *freechain, void *node)
 Pushes a node back to the freechain. More...
 
void * _Freechain_Extend (Freechain_Control *freechain, Freechain_Allocator allocator, size_t number_nodes_to_extend, size_t node_size)
 Extend the freechain with new nodes. More...
 
void * _Freechain_Get (Freechain_Control *freechain, Freechain_Allocator allocator, size_t number_nodes_to_extend, size_t node_size)
 Gets a node from the freechain. More...
 
void _Freechain_Put (Freechain_Control *freechain, void *node)
 Puts a node back onto the freechain. More...
 

Detailed Description

The Freechain Handler.

The Freechain Handler is used to manage a chain of nodes, of which size can automatically increase when there is no free node left. This handler provides one data structure: Freechain_Control.

Function Documentation

◆ _Freechain_Extend()

void* _Freechain_Extend ( Freechain_Control freechain,
Freechain_Allocator  allocator,
size_t  number_nodes_to_extend,
size_t  node_size 
)

Extend the freechain with new nodes.

Parameters
freechainThe freechain control.
allocatorThe allocator function.
number_nodes_to_extendThe number of nodes to extend.
node_sizeThe node size.
Return values
NULLThe extend operation failed.
nodesPointer to the new nodes.

◆ _Freechain_Get()

void* _Freechain_Get ( Freechain_Control freechain,
Freechain_Allocator  allocator,
size_t  number_nodes_to_extend,
size_t  node_size 
)

Gets a node from the freechain.

Parameters
[in,out]freechainThe freechain control.
allocatorThe allocator function.
number_nodes_to_extendThe number of nodes in the case an extend is necessary due to an empty freechain.
[in]node_sizeThe node size.
Return values
NULLThe freechain is empty and the extend operation failed.
pointerPointer to a node. The node ownership passes to the caller.

◆ _Freechain_Initialize()

static __inline__ void _Freechain_Initialize ( Freechain_Control freechain,
void *  initial_nodes,
size_t  number_nodes,
size_t  node_size 
)
static

Initializes a freechain.

This routine initializes the freechain control structure to manage a chain of nodes. In the case the freechain is empty the extend handler is called to get more nodes.

Parameters
[out]freechainThe freechain control to initialize.
[out]initial_nodesArray with the initial nodes.
number_nodesThe initial number of nodes.
node_sizeThe node size.

Definition at line 50 of file freechainimpl.h.

◆ _Freechain_Is_empty()

static __inline__ bool _Freechain_Is_empty ( const Freechain_Control freechain)
static

Return true if the freechain is empty, otherwise false.

Parameters
freechainThe freechain control.

Definition at line 70 of file freechainimpl.h.

◆ _Freechain_Pop()

static __inline__ void* _Freechain_Pop ( Freechain_Control freechain)
static

Pops a node from the freechain.

The freechain shall not be empty.

Parameters
freechainThe freechain control.

Definition at line 84 of file freechainimpl.h.

◆ _Freechain_Push()

static void __inline__ _Freechain_Push ( Freechain_Control freechain,
void *  node 
)
static

Pushes a node back to the freechain.

Parameters
freechainThe freechain control.
nodeThe node to push back. The node shall not be NULL.

Definition at line 95 of file freechainimpl.h.

◆ _Freechain_Put()

void _Freechain_Put ( Freechain_Control freechain,
void *  node 
)

Puts a node back onto the freechain.

Parameters
[in,out]freechainThe freechain control.
[out]nodeThe node to put back. The node may be NULL, in this case the function does nothing.