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.
◆ _Freechain_Get()
Gets a node from the freechain.
- Parameters
-
[in] | freechain | The freechain control. |
[in] | allocator | The allocator function. |
[in] | number_nodes_to_extend | The number of nodes in 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. |
otherwise | Pointer to a node. The node ownership passes to the caller. |
◆ _Freechain_Initialize()
Initializes a freechain.
This routine initializes the freechain control structure to manage a chain of nodes. In case the freechain is empty the extend handler is called to get more nodes.
- Parameters
-
[in] | freechain | The freechain control to initialize. |
[in] | initial_nodes | Array with the initial nodes. |
[in] | number_nodes | The initial number of nodes. |
[in] | node_size | The node size. |
◆ _Freechain_Put()
Puts a node back onto the freechain.
- Parameters
-
[in] | freechain | The freechain control. |
[in] | node | The node to put back. The node may be NULL , in this case the function does nothing. |