To create a chain you need to declare a chain control then add nodes to the control. Consider a user structure and chain control:
typedef struct foo
{
rtems_chain_node node;
uint8_t char* data;
} foo;
rtems_chain_control chain;
Add nodes with the following code:
rtems_chain_initialize_empty (&chain);
for (i = 0; i < count; i++)
{
foo* bar = malloc (sizeof (foo));
if (!foo)
return -1;
bar->data = malloc (size);
rtems_chain_append (&chain, &bar->node);
}
The chain is initialized and the nodes allocated and appended to the chain. This is an example of a pool of buffers.
Copyright © 1988-2008 OAR Corporation