RTEMS: Freechain Handler

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
Files | Data Structures | Typedefs | Functions
Freechain Handler
Internal » SuperCore

The Freechain Handler. More...

## Files
file | freechain.h
| Freechain Handler API.
file | freechain.c
| Freechain Handler Implementation.

## Data Structures
struct | Freechain_Control
| The freechain control. More...

## Typedefs
typedef void *(* | Freechain_Allocator) (size_t size)
| Allocator function.

## Functions
RTEMS_INLINE_ROUTINE void | _Freechain_Initialize (Freechain_Control *freechain, void *initial_nodes, size_t number_nodes, size_t node_size)
| Initializes a freechain.
RTEMS_INLINE_ROUTINE bool | _Freechain_Is_empty (const Freechain_Control *freechain)
| Return true if the freechain is empty, otherwise false.
RTEMS_INLINE_ROUTINE void * | _Freechain_Pop (Freechain_Control *freechain)
| Pop an item from the freechain.
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.
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.
void | _Freechain_Put (Freechain_Control *freechain, void *node)
| Puts a node back onto the freechain.

## 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

  freechain | The freechain control.
  allocator | The allocator function.
  number_nodes_to_extend | The number of nodes to extend.
  node_size | The node size.

Return values

  NULL | The extend operation failed.
  nodes | Pointer 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] | freechain | The freechain control.
  | allocator | The allocator function.
  | number_nodes_to_extend | The number of nodes in the case an extend is necessary due to an empty freechain.
  [in] | node_size | The node size.

Return values

  NULL | The freechain is empty and the extend operation failed.
  pointer | Pointer to a node. The node ownership passes to the caller.

## ◆ _Freechain_Initialize()

RTEMS_INLINE_ROUTINE void _Freechain_Initialize | ( | Freechain_Control * | freechain,
|  | void * | initial_nodes,
|  | size_t | number_nodes,
|  | size_t | node_size
| ) |  |

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] | freechain | The freechain control to initialize.
  [out] | initial_nodes | Array with the initial nodes.
  | number_nodes | The initial number of nodes.
  | node_size | The node size.

## ◆ _Freechain_Is_empty()

RTEMS_INLINE_ROUTINE bool _Freechain_Is_empty | ( | const Freechain_Control * | freechain | ) |

Return true if the freechain is empty, otherwise false.

Parameters

  freechain | The freechain control.

## ◆ _Freechain_Pop()

RTEMS_INLINE_ROUTINE void * _Freechain_Pop | ( | Freechain_Control * | freechain | ) |

Pop an item from the freechain.

The freechain must not be empty.

Parameters

  freechain | The freechain control.

## ◆ _Freechain_Put()

void _Freechain_Put | ( | Freechain_Control * | freechain,
|  | void * | node
| ) |  |

Puts a node back onto the freechain.

Parameters

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