You're going to have a structure like
Code:
struct fifo_element {
struct fifo_element *next;
void *data;
};
Then you can represent the whole FIFO as
Code:
struct fifo {
struct fifo_element *head;
struct fifo_element *tail;
};
To add a fifo_element *foo to a fifo bar,
Code:
struct fifo_element *foo = malloc(sizeof(*foo));
if (foo == NULL)
barf();
foo->next = NULL;
foo->data = my_important_data;
bar.tail->next = foo;
bar.tail = foo;
To pop the first fifo_element from bar,
Code:
struct fifo_element *old = bar.head;
bar.head = bar.head->next;
free_fifo_element(old);
There are special cases when the fifo is empty, since you should have head and tail == NULL, and of course you don't want to dereference that. I leave those to you