Thank you for your help! So I corrected the return statements.
I actually didn't want to confuse you with my attempt cause it makes no sense at all, but I sure can post it now.
The print_all function is obviously wrong, but I have no Idea how to print the list. Also I'm not sure how to fill the actual list with values so I got confused and this is what happend:
Code:
void test_list_functions()
{
/* write test code for list functions */
/* Init new list */
struct list_head *head = list_init(head);
struct list_head *pid = head;
int i;
/* fill with pit 1-4 */
for(i = 0; i <= 4; i++){
pid = list_init(i);
}
/* print list */
print_all(head);
print_all(pid);
pid = list_add(pid, head);
print_all(pid);
pid = list_add_tail(pid, head);
print_all(pid);
pid = list_del(pid);
print_all(pid);
pid = list_move(pid, head);
print_all(pid);
pid = list_move_tail(pid, head);
print_all(pid);
pid = list_empty(head);
print_all(head);
return 0;
}
and here is the part I corrected:
Code:
/* initialize "shortcut links" for empty list */
void
list_init(struct list_head *head)
{
head->next = head;
head->prev = head;
}
/* deletes entry from list and reinitialize it, returns pointer to entry */
struct list_head*
list_del(struct list_head *entry)
{
entry->prev->next = entry->next;
entry->next->prev = entry->prev;
entry->next = entry;
entry->prev = entry;
return(entry);
}